Skip to content

Commit ae839f3

Browse files
committed
fix: update version in package.yaml before building
This gets compiled in and used for `--version`.
1 parent 8459193 commit ae839f3

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

.github/workflows/release.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ jobs:
2727
- id: stack
2828
uses: freckle/stack-action@v5
2929
- uses: extractions/setup-just@v2
30+
31+
# Do a dry-run release in order to update package.yaml before compilation,
32+
# so the --version option works correctly.
33+
- uses: cycjimmy/semantic-release-action@v4
34+
with:
35+
dry_run: true
36+
extra_plugins: |
37+
conventional-changelog-conventionalcommits
38+
@semantic-release/exec
39+
env:
40+
FORCE_COLOR: 1
41+
GITHUB_TOKEN: ${{ github.token }}
42+
3043
- run: just dist
3144
- uses: actions/upload-artifact@v4
3245
with:
@@ -55,6 +68,7 @@ jobs:
5568
with:
5669
extra_plugins: |
5770
conventional-changelog-conventionalcommits
71+
@semantic-release/exec
5872
env:
5973
FORCE_COLOR: 1
6074
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
@@ -76,6 +90,7 @@ jobs:
7690
steps:
7791
- uses: actions/checkout@v4
7892
- run: ./install -t '${{ needs.release.outputs.tag }}'
93+
- run: restyle --version
7994
- run: restyle --help
8095

8196
docs:

.releaserc.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ plugins:
55
- preset: "conventionalcommits"
66
- - "@semantic-release/release-notes-generator"
77
- preset: "conventionalcommits"
8+
- - "@semantic-release/exec"
9+
- verifyReleaseCmd: "./bin/bump-package-yaml '${nextRelease.version}'"
810
- - "@semantic-release/github"
911
- assets: "*-binaries/restyler-*.tar.gz"
1012
successCommentCondition: false

bin/bump-package-yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if (($# != 1)); then
5+
echo "usage: bump-package-yaml <version>" >&2
6+
exit 1
7+
fi
8+
9+
IFS=.- read -r epoch _ < <(yq '.version' package.yaml)
10+
IFS=.- read -r major minor patch _ <<<"$1"
11+
12+
version=$epoch.$major.$minor.$patch
13+
14+
printf 'Updating package.yaml version to %s\n' "$version"
15+
yq -i ".version = \"$version\"" package.yaml
16+
17+
stack build --dry-run --hpack-force

0 commit comments

Comments
 (0)