Skip to content

Commit c17be8e

Browse files
committed
ci: combine both jobs in release.yml into 1
1 parent 41cb645 commit c17be8e

File tree

1 file changed

+22
-36
lines changed

1 file changed

+22
-36
lines changed

.github/workflows/release.yml

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@ on:
66
- next
77

88
jobs:
9-
create_release:
9+
release_to_npm:
1010
permissions:
1111
contents: write
1212
runs-on: ubuntu-latest
13-
outputs:
14-
is_latest: ${{ steps.release_type.outputs.is_latest }}
15-
is_new_version: ${{ steps.version_check.outputs.is_new_version }}
1613

1714
steps:
1815
- name: Checkout 🛎️
@@ -21,6 +18,23 @@ jobs:
2118
fetch-depth: 20
2219
fetch-tags: false
2320

21+
- name: Setup Node version ⚙️
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: 20
25+
registry-url: https://registry.npmjs.org/
26+
27+
- id: cache-yarn
28+
name: Restore cached node modules ♻️
29+
uses: actions/cache@v4
30+
with:
31+
path: |
32+
.yarn/cache
33+
node_modules
34+
key: ${{ inputs.os }}-${{ inputs.node }}-release-${{ hashFiles('**/yarn.lock') }}
35+
restore-keys: |
36+
${{ inputs.os }}-${{ inputs.node }}-release
37+
2438
- id: version_check
2539
name: Verify new version 🔍
2640
run: |
@@ -64,50 +78,22 @@ jobs:
6478
draft: false
6579
prerelease: ${{ steps.release_type.outputs.is_latest != 'true' }}
6680

67-
publish_to_npm:
68-
needs: create_release
69-
if: ${{ needs.create_release.outputs.is_new_version == 'true' }}
70-
runs-on: ubuntu-latest
71-
72-
steps:
73-
- name: Checkout 🛎️
74-
uses: actions/checkout@v4
75-
with:
76-
fetch-depth: 20
77-
fetch-tags: false
78-
79-
- id: cache-yarn
80-
name: Restore cached node modules ♻️
81-
uses: actions/cache@v4
82-
with:
83-
path: |
84-
.yarn/cache
85-
node_modules
86-
key: ${{ inputs.os }}-${{ inputs.node }}-release-${{ hashFiles('**/yarn.lock') }}
87-
restore-keys: |
88-
${{ inputs.os }}-${{ inputs.node }}-release
89-
90-
- name: Setup Node version ⚙️
91-
uses: actions/setup-node@v4
92-
with:
93-
node-version: 20
94-
registry-url: https://registry.npmjs.org/
95-
9681
- name: Install 🔧
97-
if: ${{ steps.cache-yarn.outputs.cache-hit != 'true' }}
82+
if: ${{ steps.version_check.outputs.is_new_version == 'true' }}
9883
run: yarn --immutable
9984

10085
- name: Build 🔨
86+
if: ${{ steps.version_check.outputs.is_new_version == 'true' }}
10187
run: yarn build
10288

10389
- name: Publish with latest tag 🚀
104-
if: ${{ needs.create_release.outputs.is_latest == 'true' }}
90+
if: ${{ steps.version_check.outputs.is_new_version == 'true' && steps.release_type.outputs.is_latest == 'true' }}
10591
run: npm publish --access public
10692
env:
10793
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
10894

10995
- name: Publish with next tag 🚀
110-
if: ${{ needs.create_release.outputs.is_latest != 'true' }}
96+
if: ${{ steps.version_check.outputs.is_new_version == 'true' && steps.release_type.outputs.is_latest != 'true' }}
11197
run: npm publish --access public --tag next
11298
env:
11399
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)