name: Release # Builds, signs, and publishes Hex for macOS, Windows, and Linux from one # exact commit to the Anomaly release service (docs/releasing.md, # docs/plans/release-service.md). The service authorizes this workflow file # by its GitHub OIDC token: repository anomalyco/hex, ref dev, production or # app-v*, environment release (anomalyco/release registry/hex.json). # # production holds what was released and only moves by a fast-forward from # dev. Run staging from dev; run stable from production or push an app-v tag. # # channel=staging (the default) is the dry run: every platform is built as # -dev. and published on the dev service's dev channel, # https://dev.anoma.ly/release (the service refuses publishing a channel's # current version again), with a draft GitHub release, and the AUR package is # built and installed but not pushed. channel=stable (or an # app-v tag) publishes to https://anoma.ly/release, the GitHub # release, the AUR, and the production site. on: workflow_dispatch: inputs: ref: description: Commit, tag, or branch to release required: true default: production channel: description: staging (dry run on dev.anoma.ly/release) 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 }} service: ${{ steps.resolve.outputs.service }} tag: ${{ steps.resolve.outputs.tag }} notes-url: ${{ steps.resolve.outputs.notes-url }} release-channel: ${{ steps.resolve.outputs.release-channel }} release-version: ${{ steps.resolve.outputs.release-version }} 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[] | select(.name == "voice-control") | .version') if ! printf '%s\n' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then echo "::error::Stable releases need an X.Y.Z version, not $version." exit 1 fi if [ "$CHANNEL" = stable ] && [ "$REF_TYPE" != tag ] && [ "$REF_NAME" != production ]; then echo "::error::Stable releases run from production or an app-v tag, not $REF_NAME." 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) service=https://anoma.ly/release tag="app-v$version" notes="https://github.com/$GITHUB_REPOSITORY/releases/tag/$tag" release_channel=stable release_version=$version ;; staging) service=https://dev.anoma.ly/release tag="staging-$GITHUB_RUN_ID" notes="https://github.com/$GITHUB_REPOSITORY/commit/$sha" release_channel=dev release_version="$version-dev.$GITHUB_RUN_NUMBER" ;; *) echo "::error::Unknown channel $CHANNEL."; exit 1 ;; esac { echo "sha=$sha" echo "version=$version" echo "channel=$CHANNEL" echo "service=$service" echo "tag=$tag" echo "notes-url=$notes" echo "release-channel=$release_channel" echo "release-version=$release_version" } >> "$GITHUB_OUTPUT" echo "Releasing $version ($CHANNEL) from $sha to $service as $release_channel $release_version." >> "$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.release-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.release-version }} # Its job runs in the release environment, which holds the Apple secrets. # Collects every platform's files into one artifact and checks them; a # staging run without the macOS build (no Apple secrets yet) goes on # without it, a stable one may not. collect: needs: [resolve, build, macos] if: >- !cancelled() && needs.build.result == 'success' && (needs.macos.result == 'success' || needs.resolve.outputs.channel == 'staging') runs-on: ubuntu-24.04 env: HEX_VERSION: ${{ needs.resolve.outputs.release-version }} CHANNEL: ${{ needs.resolve.outputs.channel }} steps: - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: pattern: hex-*-* path: dist merge-multiple: true - name: Check the release files run: | for name in hex-$HEX_VERSION-linux-x64 \ Hex-$HEX_VERSION-windows-x64.exe Hex-Setup-$HEX_VERSION-windows-x64.exe \ Hex-$HEX_VERSION-windows-arm64.exe Hex-Setup-$HEX_VERSION-windows-arm64.exe; do test -s "dist/$name" || { echo "::error::dist/$name is missing."; exit 1; } done test "$(head -c 4 "dist/hex-$HEX_VERSION-linux-x64" | od -An -tx1 | tr -d ' ')" = 7f454c46 for exe in dist/*.exe; do test "$(head -c 2 "$exe")" = MZ done if [ ! -f "dist/Hex-$HEX_VERSION-macos-arm64.zip" ]; then echo "::warning::No macOS build in this run; staging publishes Windows and Linux only." fi (cd dist && ls -l && sha256sum *) | 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: release-files path: dist/ if-no-files-found: error # The only job that can publish: its OIDC token carries the release # environment the service requires. No other credentials reach it. publish: needs: [resolve, collect] if: ${{ !cancelled() && needs.collect.result == 'success' }} runs-on: ubuntu-24.04 environment: release permissions: contents: read id-token: write env: RELEASE: ${{ needs.resolve.outputs.service }} HEX_VERSION: ${{ needs.resolve.outputs.release-version }} HEX_RELEASE_CHANNEL: ${{ needs.resolve.outputs.release-channel }} outputs: linux-url: ${{ steps.publish.outputs.linux-url }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: name: release-files path: dist - id: publish env: NOTES_URL: ${{ needs.resolve.outputs.notes-url }} run: | scripts/release-service.sh publish dist "$NOTES_URL" echo "linux-url=${RELEASE%/release}$(jq -r '.release.targets["linux-x64"].url' dist/manifest.json)" >> "$GITHUB_OUTPUT" { echo '### Manifest'; echo '```json'; cat dist/manifest.json; echo '```'; } >> "$GITHUB_STEP_SUMMARY" - name: Record the Nix flake # The flake builds this commit from source, so it serves the version now. run: scripts/release-service.sh distribution nix "$HEX_VERSION" github: name: GitHub release needs: [resolve, publish] if: ${{ !cancelled() && needs.publish.result == 'success' }} runs-on: ubuntu-24.04 permissions: contents: write env: HEX_VERSION: ${{ needs.resolve.outputs.release-version }} HEX_RELEASE_COMMIT: ${{ needs.resolve.outputs.sha }} HEX_RELEASE_CHANNEL: ${{ needs.resolve.outputs.channel }} HEX_RELEASE_TAG: ${{ needs.resolve.outputs.tag }} HEX_RELEASE_NOTES_URL: ${{ needs.resolve.outputs.service }}/hex/desktop/${{ needs.resolve.outputs.release-channel }}.json 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: release-files path: dist - env: GH_TOKEN: ${{ github.token }} run: tools/scripts/publish-github-release.sh dist aur: name: AUR needs: [resolve, publish] if: ${{ !cancelled() && needs.publish.result == 'success' }} runs-on: ubuntu-24.04 container: archlinux:base-devel environment: release env: HEX_VERSION: ${{ needs.resolve.outputs.release-version }} LINUX_URL: ${{ needs.publish.outputs.linux-url }} steps: - name: Install tools run: | pacman -Syu --noconfirm --needed git openssh useradd --create-home builder - uses: actions/checkout@v7 with: path: tools persist-credentials: false - uses: actions/download-artifact@v8 with: name: release-files path: dist - name: Stage and test hex-bin run: | chown -R builder: "$GITHUB_WORKSPACE" runuser -u builder -- tools/scripts/release-aur.sh stage "$HEX_VERSION" "dist/hex-$HEX_VERSION-linux-x64" "$LINUX_URL" 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" # The PKGBUILD's source is the published file. curl -fsS "$LINUX_URL" | cmp - "dist/hex-$HEX_VERSION-linux-x64" { 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 # Tells AUR installs about the version only once the AUR serves it. A # staging run records it on the dev service to rehearse the call. record-aur: needs: [resolve, aur] if: ${{ !cancelled() && needs.aur.result == 'success' }} runs-on: ubuntu-24.04 environment: release permissions: contents: read id-token: write env: RELEASE: ${{ needs.resolve.outputs.service }} HEX_VERSION: ${{ needs.resolve.outputs.release-version }} HEX_RELEASE_CHANNEL: ${{ needs.resolve.outputs.release-channel }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - run: scripts/release-service.sh distribution aur "$HEX_VERSION" # Renders the cask from the published DMG and checks it with brew; stable # pushes it to anomalyco/homebrew-tap with the tap's deploy key. A staging # run without a macOS build checks the cask around the frozen 2.3.1 DMG. homebrew: name: Homebrew needs: [resolve, publish] if: ${{ !cancelled() && needs.publish.result == 'success' }} runs-on: macos-15 environment: release permissions: contents: read env: RELEASE: ${{ needs.resolve.outputs.service }} HEX_VERSION: ${{ needs.resolve.outputs.release-version }} RELEASE_CHANNEL: ${{ needs.resolve.outputs.release-channel }} CHANNEL: ${{ needs.resolve.outputs.channel }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Render the cask from the published DMG run: | curl -fsS "$RELEASE/hex/desktop/$RELEASE_CHANNEL.json" -o manifest.json version=$(jq -er .release.version manifest.json) test "$version" = "$HEX_VERSION" if dmg=$(jq -ec '.release.targets["macos-arm64-dmg"]' manifest.json); then url="${RELEASE%/release}$(printf '%s' "$dmg" | jq -r .url)" sha256=$(printf '%s' "$dmg" | jq -r .sha256) elif [ "$CHANNEL" = staging ]; then echo "::warning::No macOS build in this release; checking the cask around the frozen 2.3.1 DMG." version=2.3.1 url=https://anoma.ly/hex/files/releases/HEX-2.3.1-arm64.dmg sha256=56de94665da8fefbe0fe6310368fd7b62497dff593b6818475f9c5fa751def7a else echo "::error::Hex $version has no macos-arm64-dmg build." exit 1 fi scripts/release-homebrew.sh render "$version" "$url" "$sha256" hex.rb { echo '### Casks/hex.rb'; echo '```ruby'; cat hex.rb; echo '```'; } >> "$GITHUB_STEP_SUMMARY" - name: Check it with brew env: HOMEBREW_NO_AUTO_UPDATE: "1" HOMEBREW_NO_INSTALL_FROM_API: "1" run: | brew tap anomalyco/tap cp hex.rb "$(brew --repo anomalyco/tap)/Casks/hex.rb" brew style --cask anomalyco/tap/hex brew audit --cask --strict --online anomalyco/tap/hex - name: Push to anomalyco/homebrew-tap if: needs.resolve.outputs.channel == 'stable' env: HOMEBREW_TAP_DEPLOY_KEY: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }} run: scripts/release-homebrew.sh publish hex.rb "$HEX_VERSION" # Tells Homebrew installs about the version only once the tap serves it. A # staging run records it on the dev service to rehearse the call. record-brew: needs: [resolve, homebrew] if: ${{ !cancelled() && needs.homebrew.result == 'success' }} runs-on: ubuntu-24.04 environment: release permissions: contents: read id-token: write env: RELEASE: ${{ needs.resolve.outputs.service }} HEX_VERSION: ${{ needs.resolve.outputs.release-version }} HEX_RELEASE_CHANNEL: ${{ needs.resolve.outputs.release-channel }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - run: scripts/release-service.sh distribution brew "$HEX_VERSION" 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