Release run by bleggett #210
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Binaries and Images | |
| run-name: 'Release run by ${{ github.actor }}' | |
| on: | |
| # Release unstable from HEAD on every merge | |
| push: | |
| branches: | |
| - main | |
| # Run manually to release unstable from HEAD | |
| workflow_dispatch: | |
| inputs: | |
| protect_ref: | |
| description: 'Commit/branch/tag' | |
| default: '' | |
| # Official stable versioned release | |
| release: | |
| types: | |
| - published | |
| permissions: | |
| contents: read | |
| jobs: | |
| oci: | |
| name: 'Build and publish ${{ matrix.component }} images' | |
| # if: ${{ github.repository_owner == 'edera-dev' && (github.event_name == 'release' || github.event.pull_request.head.repo.full_name == github.repository) }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| component: | |
| - edera-check | |
| permissions: | |
| contents: read | |
| id-token: write | |
| packages: write | |
| steps: | |
| - name: 'Harden runner' | |
| uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2 | |
| with: | |
| egress-policy: audit | |
| - name: 'Checkout repository' | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4.2.0 | |
| with: | |
| submodules: recursive | |
| persist-credentials: false | |
| - name: 'Setup docker buildx' | |
| uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0 | |
| with: | |
| cache-binary: false | |
| - name: 'Login to ghcr' | |
| uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 | |
| with: | |
| registry: ghcr.io | |
| username: '${{ github.actor }}' | |
| password: '${{ github.token }}' | |
| - name: Docker meta | |
| uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 | |
| id: meta | |
| with: | |
| images: | | |
| ghcr.io/edera-dev/${{ matrix.component }} | |
| tags: | | |
| # Tag with branch on push | |
| type=ref,event=branch | |
| # Tag with short sha on all events | |
| type=sha,prefix= | |
| # Tag version and stable on tag push | |
| type=semver,pattern={{raw}} | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern=stable | |
| # Tag nightly on schedule event | |
| type=schedule,pattern=nightly | |
| - name: 'Docker build and push ${{ matrix.component }}' | |
| uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2 | |
| id: push | |
| with: | |
| file: images/Containerfile.edera-check | |
| platforms: "linux/amd64,linux/arm64" | |
| tags: '${{ steps.meta.outputs.tags }}' | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| push: true | |
| - name: 'Install cosign' | |
| uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0 | |
| - name: 'Cosign sign all images' | |
| shell: bash | |
| run: | | |
| images="" | |
| for tag in ${TAGS}; do | |
| pullstring="${tag}@${DIGEST}" | |
| echo "Signing ${pullstring}" | |
| cosign sign --yes "${pullstring}" | |
| done | |
| env: | |
| TAGS: '${{ steps.meta.outputs.tags }}' | |
| DIGEST: '${{ steps.push.outputs.digest }}' | |
| build-cross: | |
| # if: ${{ github.repository_owner == 'edera-dev' && (github.event_name == 'release' || github.event.pull_request.head.repo.full_name == github.repository) }} | |
| name: Build cross-rs binaries | |
| runs-on: ubuntu-latest | |
| outputs: | |
| cross-revision: ${{ steps.build-cross.outputs.revision }} | |
| steps: | |
| - name: Harden runner | |
| uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout repository | |
| uses: actions/checkout@6b42224f41ee5dfe5395e27c8b2746f1f9955030 # v4.2.0 | |
| with: | |
| submodules: recursive | |
| persist-credentials: false | |
| - name: Build cross-rs | |
| id: build-cross | |
| uses: ./.github/actions/build-cross-rs | |
| upload-artifact: | |
| # if: ${{ github.repository_owner == 'edera-dev' && (github.event_name == 'release' || github.event.pull_request.head.repo.full_name == github.repository) }} | |
| needs: [build-cross] | |
| name: Publish Binaries to Release | |
| permissions: | |
| contents: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - { os: linux, arch: x86_64, libc: musl, static: true, on: ubuntu-latest } | |
| - { os: linux, arch: aarch64, libc: musl, static: true, on: ubuntu-latest } | |
| binary: | |
| - edera-check | |
| runs-on: '${{ matrix.platform.on }}' | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Restore cross-rs binaries | |
| uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 | |
| with: | |
| path: | | |
| ~/.cargo/bin/cross | |
| ~/.cargo/bin/cross-util | |
| key: ${{ runner.os }}-${{ runner.arch }}-cross-rs-${{ needs.build-cross.outputs.cross-revision }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 | |
| - name: 'Build and assemble ${{ matrix.binary }} ${{ matrix.platform.os }}-${{ matrix.platform.arch }}-${{ matrix.platform.libc }}' | |
| run: | | |
| set -e | |
| TARGET_ARCH="${{ matrix.platform.arch }}" | |
| TARGET_LIBC="${{ matrix.platform.libc }}" | |
| ${{ matrix.platform.static == true && 'export CARGO_BUILD_STATIC_CRT=1' || '' }} | |
| hack/build/cargo.sh build --release | |
| # Platform name | |
| PLATFORM="${{ matrix.platform.os }}-${{ matrix.platform.arch }}-${{ matrix.platform.libc }}" | |
| # Tag name | |
| TAG="${{ github.event.release.tag_name }}" | |
| [ -z "$TAG" ] && TAG="${{ github.event.repository.default_branch }}" | |
| # Assemble asset | |
| mkdir -p target/assets | |
| BINARY="${{ matrix.binary }}" | |
| OUTPUT_NAME="${BINARY}_${TAG}_${PLATFORM}" | |
| cp "target/${TARGET_ARCH}-unknown-${{ matrix.platform.os }}-${TARGET_LIBC}/release/${BINARY}" "target/assets/${OUTPUT_NAME}" | |
| cd target/assets | |
| if command -v sha256sum >/dev/null 2>&1; then | |
| sha256sum "${OUTPUT_NAME}" > "${OUTPUT_NAME}.sha256" | |
| else | |
| shasum -a 256 "${OUTPUT_NAME}" > "${OUTPUT_NAME}.sha256" | |
| fi | |
| - name: 'Upload ${{ matrix.binary }} to workflow run' | |
| uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 | |
| with: | |
| name: ${{ matrix.binary }}-${{ matrix.platform.os }}-${{ matrix.platform.arch }}-${{ matrix.platform.libc }} | |
| path: target/assets/${{ matrix.binary }}_* | |
| - name: Generate cultivator token | |
| # if: ${{ github.event_name == 'release' }} | |
| uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1 | |
| id: generate-token | |
| with: | |
| app-id: "${{ secrets.EDERA_CULTIVATION_APP_ID }}" | |
| private-key: "${{ secrets.EDERA_CULTIVATION_APP_PRIVATE_KEY }}" | |
| - name: 'Upload release artifacts with retry' | |
| # if: ${{ github.event_name == 'release' }} | |
| uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 | |
| with: | |
| timeout_minutes: 5 | |
| max_attempts: 10 | |
| retry_wait_seconds: 1 | |
| command: | | |
| cd target/assets | |
| gh release upload "${{ github.event.release.tag_name }}" --clobber ./* | |
| env: | |
| GITHUB_TOKEN: "${{ steps.generate-token.outputs.token }}" |