-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (52 loc) · 1.79 KB
/
publish.yml
File metadata and controls
68 lines (52 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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