From 1ab9f2b46958c659b74a0baa8336f7a7cb545d32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Meadows-J=C3=B6nsson?= Date: Fri, 6 Nov 2026 15:10:46 +0100 Subject: [PATCH] Check if the release is published with the hex.pm API The release workflow no longer installs the Hex archive, so `mix hex.info` failed on every push to main and the step fell through to publishing. Only publish on a 404 and fail the job on any other response. --- .github/workflows/release.yml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b4a9ae3..0ad66dd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: environment: release permissions: contents: write # push the version tag and create the GitHub release - id-token: write # the OIDC token mix hex.publish exchanges with Workload Identity + id-token: write # the OIDC token rebar3 hex publish exchanges with Workload Identity steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -82,14 +82,22 @@ jobs: - name: Publish to Hex env: - MIX_EXS: publish.exs VERSION: ${{ steps.version.outputs.version }} run: | - if mix hex.info hex_core "$VERSION"; then - echo "hex_core $VERSION is already published" - else - rebar3 hex publish --yes --wait - fi + status=$(curl --silent --show-error --output /dev/null --write-out '%{http_code}' "https://hex.pm/api/packages/hex_core/releases/$VERSION") + + case "$status" in + 200) + echo "hex_core $VERSION is already published" + ;; + 404) + rebar3 hex publish --yes --wait + ;; + *) + echo "::error::hex.pm returned HTTP $status when checking if hex_core $VERSION is published" + exit 1 + ;; + esac - name: Create the GitHub release env: