v0.1.0 (2026/01/08) #1
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: Publish to Hex.pm | |
| on: | |
| release: | |
| types: [published] | |
| permissions: | |
| contents: read | |
| env: | |
| ELIXIR_VERSION: "1.19.4" | |
| OTP_VERSION: "28" | |
| jobs: | |
| publish: | |
| name: Publish to Hex.pm | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Set up Elixir | |
| uses: erlef/setup-beam@5304e04ea2b355f03681464e683d92e3b2f18451 # v1.18.2 | |
| with: | |
| elixir-version: ${{ env.ELIXIR_VERSION }} | |
| otp-version: ${{ env.OTP_VERSION }} | |
| - name: Install dependencies | |
| run: mix deps.get | |
| - name: Validate release tag format | |
| run: | | |
| if ! [[ "$GITHUB_REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then | |
| echo "::error::Invalid release tag format: $GITHUB_REF_NAME (expected: vX.Y.Z or vX.Y.Z-suffix)" | |
| exit 1 | |
| fi | |
| - name: Verify version tag matches mix.exs | |
| run: | | |
| # Extract version from GitHub release tag (v0.1.0 -> 0.1.0) | |
| TAG_VERSION="${GITHUB_REF_NAME#v}" | |
| # Extract version from mix.exs | |
| MIX_VERSION=$(grep -oP '@version "\K[^"]+' mix.exs) | |
| echo "Tag version: $TAG_VERSION" | |
| echo "mix.exs version: $MIX_VERSION" | |
| if [ "$TAG_VERSION" != "$MIX_VERSION" ]; then | |
| echo "::error::Version mismatch! Tag ($TAG_VERSION) does not match mix.exs ($MIX_VERSION)" | |
| exit 1 | |
| fi | |
| echo "Version verified successfully: $MIX_VERSION" | |
| - name: Run tests before publish | |
| env: | |
| MIX_ENV: test | |
| run: mix test | |
| - name: Build documentation | |
| run: mix docs | |
| - name: Publish to Hex.pm | |
| env: | |
| HEX_API_KEY: ${{ secrets.HEX_API_KEY }} | |
| run: mix hex.publish --yes |