|
| 1 | +# SPDX-FileCopyrightText: Copyright 2025 Stacklok, Inc. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +name: Release |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - "v*" |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + packages: write |
| 14 | + |
| 15 | +env: |
| 16 | + GO_VERSION: "1.25" |
| 17 | + |
| 18 | +jobs: |
| 19 | + build-artifacts: |
| 20 | + name: Build (${{ matrix.arch }}) |
| 21 | + runs-on: ${{ matrix.runner }} |
| 22 | + strategy: |
| 23 | + matrix: |
| 24 | + include: |
| 25 | + - arch: amd64 |
| 26 | + runner: ubuntu-latest |
| 27 | + - arch: arm64 |
| 28 | + runner: ubuntu-24.04-arm |
| 29 | + steps: |
| 30 | + - name: Checkout repository |
| 31 | + uses: actions/checkout@v4 |
| 32 | + |
| 33 | + - name: Source versions.env |
| 34 | + run: | |
| 35 | + set -euo pipefail |
| 36 | + source versions.env |
| 37 | + echo "LIBKRUN_VERSION=${LIBKRUN_VERSION}" >> "$GITHUB_ENV" |
| 38 | +
|
| 39 | + - name: Pull builder image |
| 40 | + run: | |
| 41 | + docker pull ghcr.io/stacklok/propolis-builder:${LIBKRUN_VERSION} |
| 42 | +
|
| 43 | + - name: Extract libraries from builder image |
| 44 | + run: | |
| 45 | + id=$(docker create ghcr.io/stacklok/propolis-builder:${LIBKRUN_VERSION}) |
| 46 | + docker cp $id:/opt/libkrun-built/libkrun.so.1 . |
| 47 | + docker cp $id:/opt/libkrun-built/libkrunfw.so.5 . |
| 48 | + docker rm $id |
| 49 | +
|
| 50 | + - name: Build propolis-runner |
| 51 | + run: | |
| 52 | + docker run --rm -v $(pwd):/src:z -w /src \ |
| 53 | + -e CGO_ENABLED=1 \ |
| 54 | + ghcr.io/stacklok/propolis-builder:${LIBKRUN_VERSION} \ |
| 55 | + go build -ldflags "-X github.com/stacklok/propolis/internal/version.Version=${{ github.ref_name }} -X github.com/stacklok/propolis/internal/version.Commit=${GITHUB_SHA::8} -X github.com/stacklok/propolis/internal/version.BuildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ |
| 56 | + -o bin/propolis-runner ./runner/cmd/propolis-runner |
| 57 | +
|
| 58 | + - name: Package runtime tarball |
| 59 | + run: | |
| 60 | + staging="propolis-runtime-linux-${{ matrix.arch }}" |
| 61 | + mkdir -p "${staging}" |
| 62 | + cp bin/propolis-runner libkrun.so.1 "${staging}/" |
| 63 | + echo "${{ github.ref_name }}" > "${staging}/VERSION" |
| 64 | + tar czf "${staging}.tar.gz" "${staging}" |
| 65 | +
|
| 66 | + - name: Package firmware tarball |
| 67 | + run: | |
| 68 | + staging="propolis-firmware-linux-${{ matrix.arch }}" |
| 69 | + mkdir -p "${staging}" |
| 70 | + cp libkrunfw.so.5 "${staging}/" |
| 71 | + echo "${{ github.ref_name }}" > "${staging}/VERSION" |
| 72 | + cat > "${staging}/LICENSE-GPL" <<'EOF' |
| 73 | + libkrunfw is licensed under the GNU General Public License v2.0 (GPL-2.0). |
| 74 | + See https://github.com/containers/libkrunfw for full license text. |
| 75 | + EOF |
| 76 | + tar czf "${staging}.tar.gz" "${staging}" |
| 77 | +
|
| 78 | + - name: Upload runtime artifact |
| 79 | + uses: actions/upload-artifact@v4 |
| 80 | + with: |
| 81 | + name: propolis-runtime-linux-${{ matrix.arch }} |
| 82 | + path: propolis-runtime-linux-${{ matrix.arch }}.tar.gz |
| 83 | + |
| 84 | + - name: Upload firmware artifact |
| 85 | + uses: actions/upload-artifact@v4 |
| 86 | + with: |
| 87 | + name: propolis-firmware-linux-${{ matrix.arch }} |
| 88 | + path: propolis-firmware-linux-${{ matrix.arch }}.tar.gz |
| 89 | + |
| 90 | + create-release: |
| 91 | + name: Create Release |
| 92 | + runs-on: ubuntu-latest |
| 93 | + needs: build-artifacts |
| 94 | + steps: |
| 95 | + - name: Download all artifacts |
| 96 | + uses: actions/download-artifact@v4 |
| 97 | + with: |
| 98 | + merge-multiple: true |
| 99 | + |
| 100 | + - name: Generate checksums |
| 101 | + run: | |
| 102 | + sha256sum propolis-*.tar.gz > sha256sums.txt |
| 103 | +
|
| 104 | + - name: Create GitHub Release |
| 105 | + uses: softprops/action-gh-release@v2 |
| 106 | + with: |
| 107 | + generate_release_notes: true |
| 108 | + files: | |
| 109 | + propolis-runtime-linux-amd64.tar.gz |
| 110 | + propolis-runtime-linux-arm64.tar.gz |
| 111 | + propolis-firmware-linux-amd64.tar.gz |
| 112 | + propolis-firmware-linux-arm64.tar.gz |
| 113 | + sha256sums.txt |
| 114 | +
|
| 115 | + push-oci: |
| 116 | + name: Push OCI (${{ matrix.arch }}) |
| 117 | + runs-on: ubuntu-latest |
| 118 | + needs: build-artifacts |
| 119 | + strategy: |
| 120 | + matrix: |
| 121 | + include: |
| 122 | + - arch: amd64 |
| 123 | + - arch: arm64 |
| 124 | + steps: |
| 125 | + - name: Download runtime artifact |
| 126 | + uses: actions/download-artifact@v4 |
| 127 | + with: |
| 128 | + name: propolis-runtime-linux-${{ matrix.arch }} |
| 129 | + |
| 130 | + - name: Download firmware artifact |
| 131 | + uses: actions/download-artifact@v4 |
| 132 | + with: |
| 133 | + name: propolis-firmware-linux-${{ matrix.arch }} |
| 134 | + |
| 135 | + - name: Install oras |
| 136 | + uses: oras-project/setup-oras@v1 |
| 137 | + |
| 138 | + - name: Login to ghcr.io |
| 139 | + run: | |
| 140 | + echo "${{ secrets.GITHUB_TOKEN }}" | oras login ghcr.io -u ${{ github.actor }} --password-stdin |
| 141 | +
|
| 142 | + - name: Push runtime OCI artifact |
| 143 | + run: | |
| 144 | + oras push ghcr.io/stacklok/propolis/runtime:${{ github.ref_name }}-linux-${{ matrix.arch }} \ |
| 145 | + --artifact-type application/vnd.stacklok.propolis.runtime \ |
| 146 | + propolis-runtime-linux-${{ matrix.arch }}.tar.gz:application/gzip |
| 147 | +
|
| 148 | + - name: Push firmware OCI artifact |
| 149 | + run: | |
| 150 | + oras push ghcr.io/stacklok/propolis/firmware:${{ github.ref_name }}-linux-${{ matrix.arch }} \ |
| 151 | + --artifact-type application/vnd.stacklok.propolis.firmware \ |
| 152 | + propolis-firmware-linux-${{ matrix.arch }}.tar.gz:application/gzip |
0 commit comments