Skip to content

Commit 061c2e0

Browse files
authored
Merge pull request #50 from lpgauth/publish-from-release-script
Publish to Hex from the release script
2 parents 0563af1 + 973a4cc commit 061c2e0

2 files changed

Lines changed: 42 additions & 8 deletions

File tree

CLAUDE.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,19 @@ tag).
5959
## Releasing
6060

6161
```bash
62-
./scripts/release.sh # tags, pushes, waits for CI, generates checksums
62+
export HEX_API_KEY=... # key with api:write permission
63+
./scripts/release.sh # tag, wait for CI, checksums, commit, publish
6364
```
6465

65-
The script reads the version from `mix.exs`, creates a git tag, waits for the release workflow to build precompiled NIFs for all targets, then generates checksums. After it completes, commit the checksum file and run `mix hex.publish`.
66+
The script reads the version from `mix.exs`, creates a git tag, waits for the
67+
release workflow to build precompiled NIFs for all targets, generates checksums,
68+
commits and pushes them, then runs `mix hex.publish --yes`.
69+
70+
`HEX_API_KEY` is Hex's unencrypted write key: setting it skips the local-password
71+
prompt, which is what makes the publish step non-interactive. Mint one with
72+
`mix hex.user key generate --key-name torque-release --permission api:write`.
73+
The script fails up front (before tagging) if it's missing. To stop after
74+
checksums and publish by hand instead, run with `SKIP_PUBLISH=1`.
6675

6776
### Version bumping
6877

scripts/release.sh

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ if ! command -v gh >/dev/null 2>&1; then
3737
exit 1
3838
fi
3939

40+
if [ -z "${SKIP_PUBLISH:-}" ] && [ -z "${HEX_API_KEY:-}" ]; then
41+
echo "error: HEX_API_KEY not set — export a key with api:write permission"
42+
echo " generate: mix hex.user key generate --key-name torque-release --permission api:write"
43+
echo " or set SKIP_PUBLISH=1 to stop after checksums and publish by hand"
44+
exit 1
45+
fi
46+
4047
# Create and push tag
4148
echo "==> Creating tag ${TAG}"
4249
git tag "$TAG"
@@ -74,10 +81,28 @@ gh release edit "$TAG" --draft=false
7481
echo "==> Generating checksums..."
7582
TORQUE_BUILD=true mix rustler_precompiled.download Torque.Native --all --print
7683

77-
echo "==> Checksums written to checksum-Elixir.Torque.Native.exs"
84+
if [ -n "${SKIP_PUBLISH:-}" ]; then
85+
echo "==> Checksums written to checksum-Elixir.Torque.Native.exs"
86+
echo ""
87+
echo "Next steps:"
88+
echo " 1. git add checksum-Elixir.Torque.Native.exs"
89+
echo " 2. git commit -m 'Add checksums for ${TAG}'"
90+
echo " 3. git push origin main"
91+
echo " 4. mix hex.publish"
92+
exit 0
93+
fi
94+
95+
echo "==> Committing checksums..."
96+
git add checksum-Elixir.Torque.Native.exs
97+
if [ -n "$(git status --porcelain checksum-Elixir.Torque.Native.exs)" ]; then
98+
git commit -m "Add checksums for ${TAG}"
99+
git push origin HEAD
100+
else
101+
echo " no changes to commit"
102+
fi
103+
104+
echo "==> Publishing to Hex..."
105+
mix hex.publish --yes
106+
78107
echo ""
79-
echo "Next steps:"
80-
echo " 1. git add checksum-Elixir.Torque.Native.exs"
81-
echo " 2. git commit -m 'Add checksums for ${TAG}'"
82-
echo " 3. git push origin main"
83-
echo " 4. mix hex.publish"
108+
echo "==> torque ${TAG} published"

0 commit comments

Comments
 (0)