-
Notifications
You must be signed in to change notification settings - Fork 7
77 lines (65 loc) · 2.36 KB
/
publish.yml
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
69
70
71
72
73
74
75
76
77
# make sure dist is up-to-date and automatically update major tags to latest revision tag SHA
name: Publish
on:
release:
types: [published, edited]
jobs:
build:
runs-on: ubuntu-latest
steps:
# set env
- name: Set env for major version and release branch
run: |
echo "MAJOR_TAG=$( cut -d '.' -f 1 <<< ${{ github.event.release.tag_name }} )" >> $GITHUB_ENV
echo "RELEASE_BRANCH=release/$( cut -d '.' -f 1 <<< ${{ github.event.release.tag_name }} )" >> $GITHUB_ENV
# check env set correctly
- name: Check env var
run: |
echo $MAJOR_TAG
echo $RELEASE_BRANCH
# checkout full repo
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}
fetch-depth: '0'
- name: Config user name and email
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# checkout release branch or create if doesn't exist
- name: Check/Create release branch
run: git switch $RELEASE_BRANCH || git switch -c $RELEASE_BRANCH
# merge release tag
- name: Merge release branch with release tag
run: git merge ${{ github.event.release.tag_name }}
# build dist
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Rebuild dist
run: |
npm ci
npm run build
# commit dist changes
- name: Commit dist changes
run: |
git add dist/
git commit -m "Update dist for release" || exit 0
# push new commit
- name: Push commits
run: git push origin $RELEASE_BRANCH
# update release and re-tag
- name: Update release tag
run: |
releasetag=${{ github.event.release.tag_name }}
tagmessage=$(git tag -l --format='%(contents)' $releasetag)
git tag -f -a $releasetag -m "$tagmessage"
git push origin $releasetag -f
# update major tag
- name: Update major tag
run: |
git tag -f -a $MAJOR_TAG -m "Updated $MAJOR_TAG tag"
git push origin $MAJOR_TAG -f
echo "Updated $MAJOR_TAG tag to point to ${{ github.event.release.tag_name }} tag."