Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
skyzyx committed Apr 24, 2024
1 parent 53de8c4 commit 185e063
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/_build-and-cache-by-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
run: |
# Run the compile script for Ubuntu 22.04
# Variables are defined by the Docker container this is running in.
bash "./compile-${OS_DIST}-${OS_DIST_VER}.sh"
bash "./compile-${OS_DIST}-${OS_DIST_NAME}.sh"
- name: Package the compiled software
working-directory: packages/${{ inputs.package-name }}
Expand All @@ -67,11 +67,11 @@ jobs:
echo -n "${GPG_KEY_B64}" | base64 --decode > 3C7658F0.asc
mkdir -p ./dist
nfpm package --config nfpm-${OS_DIST}-${OS_DIST_VER}.yaml --packager deb --target ./dist
nfpm package --config nfpm-${OS_DIST}-${OS_DIST_NAME}.yaml --packager deb --target ./dist
- name: Cache the packages
uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
id: cache-packages
with:
key: "${{ inputs.package-name }}-${{ inputs.package-version }}-${OS_DIST}-${OS_DIST_VER}-${{ matrix.Arch }}"
key: "${{ inputs.package-name }}-${{ inputs.package-version }}-${OS_DIST}-${OS_DIST_NAME}-${{ matrix.Arch }}"
path: packages/${{ inputs.package-name }}/dist
1 change: 1 addition & 0 deletions buildboxes/ubuntu/Dockerfile.v20.04
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM."
# Identify ourselves
ENV OS_DIST ubuntu
ENV OS_DIST_VER 20.04
ENV OS_DIST_NAME focal
ENV OS_DIST_PKG deb

# Environment variables
Expand Down
1 change: 1 addition & 0 deletions buildboxes/ubuntu/Dockerfile.v22.04
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM."
# Identify ourselves
ENV OS_DIST ubuntu
ENV OS_DIST_VER 22.04
ENV OS_DIST_NAME jammy
ENV OS_DIST_PKG deb

# Environment variables
Expand Down
7 changes: 4 additions & 3 deletions buildboxes/ubuntu/_dockerfile.gotmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1
FROM --platform=$TARGETPLATFORM ubuntu:{{ .UbuntuVersion }}
FROM --platform=$TARGETPLATFORM ubuntu:{{ .UbuntuVersion.Version }}
SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]

{{ .DoNotEdit }}
Expand All @@ -11,7 +11,8 @@ RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM."

# Identify ourselves
ENV OS_DIST ubuntu
ENV OS_DIST_VER {{ .UbuntuVersion }}
ENV OS_DIST_VER {{ .UbuntuVersion.Version }}
ENV OS_DIST_NAME {{ .UbuntuVersion.Codename }}
ENV OS_DIST_PKG deb

# Environment variables
Expand Down Expand Up @@ -89,7 +90,7 @@ ARG BUILD_DATE
ARG VCS_REF

# https://github.com/opencontainers/image-spec/blob/master/annotations.md
LABEL org.opencontainers.image.title="Package Builder: Ubuntu {{ .UbuntuVersion }}"
LABEL org.opencontainers.image.title="Package Builder: Ubuntu {{ .UbuntuVersion.Version }}"
LABEL org.opencontainers.image.description="Container image to help facilitate building packages for Ubuntu."
LABEL org.opencontainers.image.url="https://github.com/northwood-labs/package-building"
LABEL org.opencontainers.image.documentation="https://github.com/northwood-labs/package-building/wiki"
Expand Down
17 changes: 12 additions & 5 deletions buildboxes/ubuntu/generate-from-templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,17 @@ DO NOT EDIT THIS FILE!
`))
)

// JsonConfig models the JSON config file.
type JsonConfig struct {
UbuntuVersions []string `json:"UbuntuVersions"`
}
type (
// JsonConfig models the JSON config file.
JsonConfig struct {
UbuntuVersions []UbuntuIdent `json:"UbuntuVersions"`
}

UbuntuIdent struct {
Codename string `json:"Codename"`
Version string `json:"Version"`
}
)

func main() {
// Read the templates into memory.
Expand All @@ -53,7 +60,7 @@ func main() {
ubuntuVersion := config.UbuntuVersions[i]

// Create the Dockerfile for the specific Java version.
dockerfileFile, err := os.Create(fmt.Sprintf("Dockerfile.v%s", ubuntuVersion))
dockerfileFile, err := os.Create(fmt.Sprintf("Dockerfile.v%s", ubuntuVersion.Version))
if err != nil {
log.Fatal(err)
}
Expand Down
10 changes: 8 additions & 2 deletions buildboxes/ubuntu/template-values.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"UbuntuVersions": [
"20.04",
"22.04"
{
"Version": "20.04",
"Codename": "focal"
},
{
"Version": "22.04",
"Codename": "jammy"
}
]
}

0 comments on commit 185e063

Please sign in to comment.