|
1 | 1 | name: Release
|
| 2 | + |
2 | 3 | on:
|
3 | 4 | workflow_dispatch:
|
4 | 5 | inputs:
|
5 | 6 | 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)" |
7 | 8 | default: "patch"
|
8 | 9 | required: false
|
9 | 10 |
|
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + |
10 | 14 | jobs:
|
11 | 15 | release:
|
12 | 16 | 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' }} |
19 | 18 |
|
20 | 19 | steps:
|
21 |
| - - name: Checkout |
22 |
| - uses: actions/checkout@v3 |
| 20 | + - name: Checkout repository |
| 21 | + uses: actions/checkout@v4 |
23 | 22 | with:
|
24 | 23 | 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)" |
29 | 24 |
|
30 |
| - - uses: actions/cache@v3 |
31 |
| - id: yarn-cache |
| 25 | + - name: Setup Node.js 22.x |
| 26 | + uses: actions/setup-node@v4 |
32 | 27 | 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' |
36 | 30 |
|
37 | 31 | - name: Install dependencies
|
38 |
| - if: steps.yarn-cache-dir-path.outputs.cache-hit != 'true' |
39 |
| - run: yarn install |
| 32 | + run: yarn install --frozen-lockfile |
40 | 33 |
|
41 |
| - - name: Build |
| 34 | + - name: Build the project |
42 | 35 | run: yarn build
|
43 | 36 |
|
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 }} |
46 | 39 |
|
47 |
| - - name: Update changelog |
| 40 | + - name: Update changelog |
48 | 41 | id: changelog
|
49 | 42 | run: |
|
| 43 | + yarn install |
50 | 44 | 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')" |
57 | 47 |
|
58 | 48 | - name: Log changes
|
59 | 49 | run: |
|
60 | 50 | echo "The changelog will be : ${{ steps.changelog.outputs.body }}"
|
61 |
| - |
| 51 | +
|
62 | 52 | - name: Get version
|
63 | 53 | 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")" |
65 | 55 |
|
66 |
| - - name: Create tag |
| 56 | + - name: Commit and tag release |
67 | 57 | run: |
|
68 | 58 | git config user.name github-actions[bot]
|
69 | 59 | git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
70 | 60 | 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 |
75 | 64 |
|
76 |
| - - name: Create release |
77 |
| - uses: softprops/action-gh-release@v1 |
| 65 | + - name: Create GitHub release |
| 66 | + uses: softprops/action-gh-release@v2 |
78 | 67 | with:
|
79 | 68 | body: ${{ steps.changelog.outputs.body }}
|
80 | 69 | tag_name: v${{ steps.package-version.outputs.current-version }}
|
81 | 70 | name: v${{ steps.package-version.outputs.current-version }}
|
82 | 71 |
|
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 |
| - |
89 | 72 | - name: Publish to NPM
|
90 | 73 | run: npm publish --access public
|
91 | 74 | env:
|
92 |
| - VERSION: ${{ steps.package-version.outputs.current-version }} |
93 | 75 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
0 commit comments