|
1 | | -name: Publish |
2 | | -on: |
3 | | - release: |
4 | | - types: published |
5 | | -permissions: |
6 | | - contents: write |
7 | | - |
8 | | -jobs: |
9 | | - build: |
10 | | - name: Build |
11 | | - runs-on: ubuntu-latest |
12 | | - outputs: |
13 | | - tag: ${{ steps.update-package-version.outputs.version }} |
14 | | - steps: |
15 | | - - uses: actions/checkout@v5 |
16 | | - - name: Configure git |
17 | | - run: | |
18 | | - git config user.name 'Release Action' |
19 | | - git config user.email '<>' |
20 | | - - uses: actions/setup-node@v5 |
21 | | - with: |
22 | | - node-version: 20 |
23 | | - |
24 | | - # Call `npm version`. It increments the version and commits the changes. |
25 | | - # We'll save the output (new version string) for use in the following |
26 | | - # steps |
27 | | - - name: Update package version |
28 | | - id: update-package-version |
29 | | - run: | |
30 | | - git tag -d "${{ github.event.release.tag_name }}" |
31 | | - VERSION=$(npm version "${{ github.event.release.tag_name }}" --no-git-tag-version) |
32 | | - git add package.json package-lock.json |
33 | | - git commit -m "[skip ci] Bump $VERSION" |
34 | | - git push origin HEAD:main |
35 | | - |
36 | | - # Now carry on, business as usual |
37 | | - - name: Perform npm tasks |
38 | | - run: npm run ci |
39 | | - |
40 | | - # Finally, create a detached commit containing the built artifacts and tag |
41 | | - # it with the release. Note: the fact that the branch is locally updated |
42 | | - # will not be relayed (pushed) to origin |
43 | | - - name: Commit to release branch |
44 | | - id: release_info |
45 | | - run: | |
46 | | - # Check for semantic versioning |
47 | | - longVersion="${{github.event.release.tag_name}}" |
48 | | - echo "Preparing release for version $longVersion" |
49 | | - [[ $longVersion == v[0-9]*.[0-9]*.[0-9]* ]] || (echo "must follow semantic versioning" && exit 1) |
50 | | - majorVersion=$(echo ${longVersion%.*.*}) |
51 | | - minorVersion=$(echo ${longVersion%.*}) |
52 | | -
|
53 | | - # Add the built artifacts. Using --force because dist/lib should be in |
54 | | - # .gitignore |
55 | | - git add --force dist lib |
56 | | -
|
57 | | - # Make the commit |
58 | | - MESSAGE="Build for $(git rev-parse --short HEAD)" |
59 | | - git commit --allow-empty -m "$MESSAGE" |
60 | | - git tag -f -a -m "Release $longVersion" $longVersion |
61 | | -
|
62 | | - # Get the commit of the tag you just released |
63 | | - commitHash=$(git rev-list -n 1 $longVersion) |
64 | | - |
65 | | - # Delete the old major and minor version tags locally |
66 | | - git tag -d $majorVersion || true |
67 | | - git tag -d $minorVersion || true |
68 | | - |
69 | | - # Make new major and minor version tags locally that point to the commit you got from the "git rev-list" above |
70 | | - git tag -f $majorVersion $commitHash |
71 | | - git tag -f $minorVersion $commitHash |
72 | | - |
73 | | - # Force push the new minor version tag to overwrite the old tag remotely |
74 | | - echo "Pushing new tags" |
75 | | - git push -f origin $longVersion |
76 | | - git push -f origin $majorVersion |
77 | | - git push -f origin $minorVersion |
| 1 | +name: Publish |
| 2 | +on: |
| 3 | + release: |
| 4 | + types: published |
| 5 | +permissions: |
| 6 | + contents: write |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + name: Build |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: |
| 13 | + tag: ${{ steps.update-package-version.outputs.version }} |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v5 |
| 16 | + - name: Configure git |
| 17 | + run: | |
| 18 | + git config user.name 'Release Action' |
| 19 | + git config user.email '<>' |
| 20 | + - uses: actions/setup-node@v5 |
| 21 | + with: |
| 22 | + node-version: 24 |
| 23 | + |
| 24 | + # Call `npm version`. It increments the version and commits the changes. |
| 25 | + # We'll save the output (new version string) for use in the following |
| 26 | + # steps |
| 27 | + - name: Update package version |
| 28 | + id: update-package-version |
| 29 | + run: | |
| 30 | + git tag -d "${{ github.event.release.tag_name }}" |
| 31 | + VERSION=$(npm version "${{ github.event.release.tag_name }}" --no-git-tag-version) |
| 32 | + git add package.json package-lock.json |
| 33 | + git commit -m "[skip ci] Bump $VERSION" |
| 34 | + git push origin HEAD:main |
| 35 | + |
| 36 | + # Now carry on, business as usual |
| 37 | + - name: Perform npm tasks |
| 38 | + run: npm run ci |
| 39 | + |
| 40 | + # Finally, create a detached commit containing the built artifacts and tag |
| 41 | + # it with the release. Note: the fact that the branch is locally updated |
| 42 | + # will not be relayed (pushed) to origin |
| 43 | + - name: Commit to release branch |
| 44 | + id: release_info |
| 45 | + run: | |
| 46 | + # Check for semantic versioning |
| 47 | + longVersion="${{github.event.release.tag_name}}" |
| 48 | + echo "Preparing release for version $longVersion" |
| 49 | + [[ $longVersion == v[0-9]*.[0-9]*.[0-9]* ]] || (echo "must follow semantic versioning" && exit 1) |
| 50 | + majorVersion=$(echo ${longVersion%.*.*}) |
| 51 | + minorVersion=$(echo ${longVersion%.*}) |
| 52 | +
|
| 53 | + # Add the built artifacts. Using --force because dist/lib should be in |
| 54 | + # .gitignore |
| 55 | + git add --force dist lib |
| 56 | +
|
| 57 | + # Make the commit |
| 58 | + MESSAGE="Build for $(git rev-parse --short HEAD)" |
| 59 | + git commit --allow-empty -m "$MESSAGE" |
| 60 | + git tag -f -a -m "Release $longVersion" $longVersion |
| 61 | +
|
| 62 | + # Get the commit of the tag you just released |
| 63 | + commitHash=$(git rev-list -n 1 $longVersion) |
| 64 | + |
| 65 | + # Delete the old major and minor version tags locally |
| 66 | + git tag -d $majorVersion || true |
| 67 | + git tag -d $minorVersion || true |
| 68 | + |
| 69 | + # Make new major and minor version tags locally that point to the commit you got from the "git rev-list" above |
| 70 | + git tag -f $majorVersion $commitHash |
| 71 | + git tag -f $minorVersion $commitHash |
| 72 | + |
| 73 | + # Force push the new minor version tag to overwrite the old tag remotely |
| 74 | + echo "Pushing new tags" |
| 75 | + git push -f origin $longVersion |
| 76 | + git push -f origin $majorVersion |
| 77 | + git push -f origin $minorVersion |
0 commit comments