name: Release # Builds, signs, and publishes Hex for macOS, Windows, and Linux from one # exact commit. Feeds are signed in a job that never compiles code; the # publish job uploads to the hex-production-files R2 bucket behind # https://anoma.ly/hex/files, mirrors the downloads to a GitHub release, # updates the AUR package, and deploys the production site. # # channel=staging (the default) is a dry run: everything lands in the dev # bucket under https://dev.anoma.ly/hex/files/staging// and in a # draft GitHub release, and the AUR package is built and tested but not # pushed. Installed apps never read it unless HEX_RELEASE_BASE_URL points # them at it. channel=stable (or an app-v tag) publishes the public # release. # See docs/releasing.md. on: workflow_dispatch: inputs: ref: description: Commit, tag, or branch to release required: true default: main channel: description: staging (dry run under staging//) or stable (public) type: choice options: [staging, stable] default: staging push: tags: ["app-v*"] permissions: contents: read concurrency: group: release-${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }} cancel-in-progress: false jobs: resolve: runs-on: ubuntu-24.04 outputs: sha: ${{ steps.resolve.outputs.sha }} version: ${{ steps.resolve.outputs.version }} channel: ${{ steps.resolve.outputs.channel }} prefix: ${{ steps.resolve.outputs.prefix }} bucket: ${{ steps.resolve.outputs.bucket }} base-url: ${{ steps.resolve.outputs.base-url }} tag: ${{ steps.resolve.outputs.tag }} steps: - uses: actions/checkout@v7 with: ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.ref }} persist-credentials: false - id: resolve env: EVENT: ${{ github.event_name }} REF_NAME: ${{ github.ref_name }} REF_TYPE: ${{ github.ref_type }} CHANNEL: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }} run: | sha=$(git rev-parse HEAD) version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') if ! printf '%s\n' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then echo "::error::Releases need a non-prerelease version, not $version." exit 1 fi if [ "$EVENT:$REF_TYPE" = push:tag ] && [ "$REF_NAME" != "app-v$version" ]; then echo "::error::Tag $REF_NAME does not match version $version." exit 1 fi case "$CHANNEL" in stable) base=https://anoma.ly/hex/files bucket=hex-production-files prefix= tag="app-v$version" ;; staging) base=https://dev.anoma.ly/hex/files bucket=hex-dev-files prefix="staging/$GITHUB_RUN_ID/" tag="staging-$GITHUB_RUN_ID" ;; *) echo "::error::Unknown channel $CHANNEL."; exit 1 ;; esac { echo "sha=$sha" echo "version=$version" echo "channel=$CHANNEL" echo "prefix=$prefix" echo "bucket=$bucket" echo "base-url=$base${prefix:+/${prefix%/}}" echo "tag=$tag" } >> "$GITHUB_OUTPUT" echo "Releasing $version ($CHANNEL) from $sha to $base${prefix:+/${prefix%/}}." >> "$GITHUB_STEP_SUMMARY" build: needs: resolve permissions: contents: read id-token: write uses: ./.github/workflows/build-desktop.yml with: sha: ${{ needs.resolve.outputs.sha }} version: ${{ needs.resolve.outputs.version }} sign-windows: true # Azure Artifact Signing (OIDC); the values live in the release environment. secrets: AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }} AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }} AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE }} macos: needs: resolve uses: ./.github/workflows/build-macos.yml with: sha: ${{ needs.resolve.outputs.sha }} version: ${{ needs.resolve.outputs.version }} download-base: ${{ needs.resolve.outputs.base-url }} require-newer: ${{ needs.resolve.outputs.channel == 'stable' }} secrets: inherit sign: name: Sign and validate needs: [resolve, build] runs-on: ubuntu-24.04 environment: release env: HEX_VERSION: ${{ needs.resolve.outputs.version }} HEX_RELEASE_BASE_URL: ${{ needs.resolve.outputs.base-url }} CHANNEL: ${{ needs.resolve.outputs.channel }} FEEDS: linux-update.json windows-update.json windows-aarch64-update.json steps: - uses: actions/checkout@v7 with: path: tools persist-credentials: false # Named per platform: hex-macos-arm64 belongs to the publish job. - uses: actions/download-artifact@v8 with: pattern: hex-linux-* path: dist merge-multiple: true - uses: actions/download-artifact@v8 with: pattern: hex-windows-* path: dist merge-multiple: true - name: Sign the update feeds env: HEX_RELEASE_SIGNING_KEY: ${{ secrets.HEX_RELEASE_SIGNING_KEY }} run: tools/scripts/release-feed.sh sign dist $FEEDS - name: Verify signatures, artifacts, and version order env: SHA: ${{ needs.resolve.outputs.sha }} run: | tools/scripts/release-feed.sh verify dist $FEEDS jq -n --arg commit "$SHA" --arg version "$HEX_VERSION" '{commit:$commit,version:$version}' > dist/release.json for feed in $FEEDS; do jq -r .payload "dist/$feed" | base64 -d | jq -c . | tee -a "$GITHUB_STEP_SUMMARY" done for label in x64 arm64; do test -s "dist/HEX-Setup-$HEX_VERSION-$label.exe" test "$(head -c 2 "dist/HEX-Setup-$HEX_VERSION-$label.exe")" = MZ done (cd dist && sha256sum HEX-Setup-*.exe) | tee -a "$GITHUB_STEP_SUMMARY" - name: Require Authenticode signatures for stable run: | sudo apt-get install -y -qq osslsigncode >/dev/null unsigned= for exe in dist/*.exe; do if osslsigncode extract-signature -in "$exe" -out "$RUNNER_TEMP/signature" >/dev/null 2>&1; then echo "Signed: $(basename "$exe")" >> "$GITHUB_STEP_SUMMARY" else unsigned="$unsigned $(basename "$exe")" fi rm -f "$RUNNER_TEMP/signature" done if [ -n "$unsigned" ]; then if [ "$CHANNEL" = stable ]; then echo "::error::Stable releases need Authenticode-signed Windows executables:$unsigned" exit 1 fi echo "::warning::Unsigned Windows executables:$unsigned" fi - uses: actions/upload-artifact@v7 with: name: signed-release path: | dist/HEX-* dist/*-update.json dist/release.json if-no-files-found: error publish: name: Publish needs: [resolve, sign, macos] # A staging dry run publishes without macOS when its build failed (for # example before the Apple secrets exist); stable needs every platform. if: >- !cancelled() && needs.sign.result == 'success' && (needs.macos.result == 'success' || needs.resolve.outputs.channel == 'staging') runs-on: ubuntu-24.04 environment: release permissions: contents: write env: HEX_VERSION: ${{ needs.resolve.outputs.version }} HEX_RELEASE_COMMIT: ${{ needs.resolve.outputs.sha }} HEX_RELEASE_CHANNEL: ${{ needs.resolve.outputs.channel }} HEX_RELEASE_BASE_URL: ${{ needs.resolve.outputs.base-url }} HEX_RELEASE_PREFIX: ${{ needs.resolve.outputs.prefix }} HEX_RELEASE_BUCKET: ${{ needs.resolve.outputs.bucket }} HEX_RELEASE_TAG: ${{ needs.resolve.outputs.tag }} HEX_RELEASE_SOURCE: ${{ github.workspace }}/source steps: - uses: actions/checkout@v7 with: path: tools persist-credentials: false # Credentials stay so a stable release can push its tag. - uses: actions/checkout@v7 with: ref: ${{ needs.resolve.outputs.sha }} path: source - uses: actions/download-artifact@v8 with: name: signed-release path: dist - uses: actions/download-artifact@v8 if: needs.macos.result == 'success' with: name: hex-macos-arm64 path: dist - name: Publish env: GH_TOKEN: ${{ github.token }} R2_ACCESS_KEY_ID: ${{ vars.R2_ACCESS_KEY_ID }} R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} run: tools/scripts/publish-release.sh dist aur: name: AUR needs: [resolve, sign, publish] if: ${{ !cancelled() && needs.publish.result == 'success' }} runs-on: ubuntu-24.04 container: archlinux:base-devel environment: release env: HEX_VERSION: ${{ needs.resolve.outputs.version }} steps: - name: Install tools run: | pacman -Syu --noconfirm --needed git openssh jq openssl useradd --create-home builder - uses: actions/checkout@v7 with: path: tools persist-credentials: false - uses: actions/download-artifact@v8 with: name: signed-release path: dist - name: Stage and test hex-bin run: | artifact=$(jq -r .payload dist/linux-update.json | openssl base64 -d -A | jq -r .artifact) chown -R builder: "$GITHUB_WORKSPACE" runuser -u builder -- tools/scripts/release-aur.sh stage "$HEX_VERSION" "dist/$artifact" aur runuser -u builder -- tools/scripts/release-aur.sh test aur pacman -U --noconfirm aur/hex-bin-*.pkg.tar.zst test "$(hex --version | awk 'NF { value=$NF } END { print value }')" = "$HEX_VERSION" { echo '### AUR PKGBUILD'; echo '```'; cat aur/PKGBUILD; echo '```'; } >> "$GITHUB_STEP_SUMMARY" - name: Push to the AUR if: needs.resolve.outputs.channel == 'stable' env: AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }} run: tools/scripts/release-aur.sh publish aur site: name: Deploy the production site needs: [resolve, publish] if: ${{ !cancelled() && needs.publish.result == 'success' && needs.resolve.outputs.channel == 'stable' }} uses: ./.github/workflows/site-deploy.yml with: mode: production secrets: inherit