Skip to content

Commit 31f13b6

Browse files
Set extension version and update CANGELOG.md (#40)
1 parent ad0fc89 commit 31f13b6

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,30 @@ jobs:
2929
always-auth: true
3030
cache: 'yarn'
3131

32+
- name: Set version
33+
run: |
34+
case ${{ github.event_name }} in
35+
release)
36+
TAG="${{ github.event.release.tag_name }}"
37+
yarn version --no-git-tag-version --new-version "${TAG#v}"
38+
;;
39+
pull_request)
40+
DESCRIBE=$(git describe --tags | grep -Eo 'v[0-9]+\.[0-9]+\.[0-9]+')
41+
QUALIFIER=$(git describe --tags | grep -Eo '\-g[0-9a-f]+$')
42+
yarn version -s --no-git-tag-version --new-version "${DESCRIBE#v}"
43+
yarn version --no-git-tag-version --prepatch --preid "pr${{ github.event.number }}${QUALIFIER}"
44+
;;
45+
*)
46+
DESCRIBE=$(git describe --tags | grep -Eo 'v[0-9]+\.[0-9]+\.[0-9]+')
47+
QUALIFIER=$(git describe --tags | grep -Eo '[0-9]+\-g[0-9a-f]+$')
48+
yarn version -s --no-git-tag-version --new-version "${DESCRIBE#v}"
49+
yarn version --no-git-tag-version --prepatch --preid "${{ github.ref_name }}${QUALIFIER}"
50+
;;
51+
esac
52+
VERSION="$(jq -r ".version" < package.json)"
53+
sed -i "s/## Unreleased/## ${VERSION}/" CHANGELOG.md
54+
echo "Version is ${VERSION}"
55+
3256
- name: Build
3357
env:
3458
GITHUB_TOKEN: ${{github.token}}
@@ -42,9 +66,22 @@ jobs:
4266
with:
4367
name: dist
4468
path: |
69+
./CHANGELOG.md
70+
./package.json
4571
./dist
4672
retention-days: 1
4773

74+
- name: Commit changelog
75+
if: github.event_name == 'release'
76+
run: |
77+
sed -i '3i ## Unreleased\n' CHANGELOG.md
78+
git checkout main
79+
git config user.name github-actions
80+
git config user.email [email protected]
81+
git add CHANGELOG.md
82+
git commit -m "Update CHANGELOG.md after release [skip ci]"
83+
git push
84+
4885
package:
4986
name: Package
5087
runs-on: [ubuntu-latest]
@@ -73,7 +110,7 @@ jobs:
73110
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
74111
with:
75112
name: dist
76-
path: dist
113+
path: .
77114

78115
- name: Cache tools
79116
uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.6

0 commit comments

Comments
 (0)