Skip to content

Commit 2afacab

Browse files
committed
ci(3.0): simplify release step and build Typescript files
1 parent 47c134a commit 2afacab

File tree

1 file changed

+28
-46
lines changed

1 file changed

+28
-46
lines changed

.github/workflows/release.yml

+28-46
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,75 @@
11
name: Release
2+
23
on:
34
workflow_dispatch:
45
inputs:
56
strategy:
6-
description: Valid semver number <x.x.x> or strategy <patch, minor, major>
7+
description: "Valid semver (x.x.x) or strategy (patch, minor, major)"
78
default: "patch"
89
required: false
910

11+
permissions:
12+
contents: write
13+
1014
jobs:
1115
release:
1216
runs-on: ubuntu-latest
13-
14-
strategy:
15-
matrix:
16-
node-version: [18.x]
17-
18-
if: ${{ github.actor == 'pebie' || github.actor == 'Crow-EH' || github.actor == 'fthouraud' || github.actor == 'leguellec' || github.actor == 'rande' }}
17+
if: ${{ github.actor == 'pebie' || github.actor == 'leguellec' }}
1918

2019
steps:
21-
- name: Checkout
22-
uses: actions/checkout@v3
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
2322
with:
2423
fetch-depth: 0
25-
26-
- name: Get yarn cache directory path
27-
id: yarn-cache-dir-path
28-
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
2924

30-
- uses: actions/cache@v3
31-
id: yarn-cache
25+
- name: Setup Node.js 22.x
26+
uses: actions/setup-node@v4
3227
with:
33-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
34-
key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
35-
restore-keys: ${{ runner.os }}-yarn-
28+
node-version: '22.x'
29+
registry-url: 'https://registry.npmjs.org'
3630

3731
- name: Install dependencies
38-
if: steps.yarn-cache-dir-path.outputs.cache-hit != 'true'
39-
run: yarn install
32+
run: yarn install --frozen-lockfile
4033

41-
- name: Build
34+
- name: Build the project
4235
run: yarn build
4336

44-
- name: Bump the version using input strategy
45-
run: yarn version --new-version ${{ github.event.inputs.strategy }} --no-git-tag-version
37+
- name: Bump version
38+
run: yarn version ${{ github.event.inputs.strategy }}
4639

47-
- name: Update changelog
40+
- name: Update changelog
4841
id: changelog
4942
run: |
43+
yarn install
5044
CHANGELOG=$(yarn conventional-changelog -p conventionalcommits -r -u 0)
51-
echo -e "${CHANGELOG}\n\n\n\n$(cat CHANGELOG.md)" > CHANGELOG.md
52-
BODY=$(echo -e "${CHANGELOG}" | sed -e "1,2d")
53-
BODY="${BODY//'%'/'%25'}"
54-
BODY="${BODY//$'\n'/'%0A'}"
55-
BODY="${BODY//$'\r'/'%0D'}"
56-
echo "::set-output name=body::${BODY}"
45+
echo -e "${CHANGELOG}\n\n$(cat CHANGELOG.md)" > CHANGELOG.md
46+
echo "::set-output name=body::$(echo "${CHANGELOG}" | tail -n +3 | sed ':a;N;$!ba;s/\n/%0A/g;s/\r/%0D/g')"
5747
5848
- name: Log changes
5949
run: |
6050
echo "The changelog will be : ${{ steps.changelog.outputs.body }}"
61-
51+
6252
- name: Get version
6353
id: package-version
64-
uses: martinbeentjes/npm-get-version-action@v1.2.3
54+
run: echo "::set-output name=current-version::$(node -p "require('./package.json').version")"
6555

66-
- name: Create tag
56+
- name: Commit and tag release
6757
run: |
6858
git config user.name github-actions[bot]
6959
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
7060
git add .
71-
git commit -m "chore(bump): release v${{ steps.package-version.outputs.current-version }}"
72-
git push
73-
git tag -a v${{ steps.package-version.outputs.current-version }} -m "chore(tag): release v${{ steps.package-version.outputs.current-version }}"
74-
git push origin v${{ steps.package-version.outputs.current-version }}
61+
git commit -m "chore(release): v${{ steps.package-version.outputs.current-version }}"
62+
git tag v${{ steps.package-version.outputs.current-version }}
63+
git push --follow-tags
7564
76-
- name: Create release
77-
uses: softprops/action-gh-release@v1
65+
- name: Create GitHub release
66+
uses: softprops/action-gh-release@v2
7867
with:
7968
body: ${{ steps.changelog.outputs.body }}
8069
tag_name: v${{ steps.package-version.outputs.current-version }}
8170
name: v${{ steps.package-version.outputs.current-version }}
8271

83-
- name: Setup npmrc
84-
uses: actions/setup-node@v3
85-
with:
86-
node-version: '18.x'
87-
registry-url: 'https://registry.npmjs.org'
88-
8972
- name: Publish to NPM
9073
run: npm publish --access public
9174
env:
92-
VERSION: ${{ steps.package-version.outputs.current-version }}
9375
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)