Skip to content

Commit 061515a

Browse files
committed
feat: update release workflow to use a preparation step
1 parent faeefdd commit 061515a

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

.github/workflows/release.yml

+39-15
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,46 @@ on:
66
workflow_dispatch:
77

88
jobs:
9+
preparation:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: read
14+
actions: read
15+
16+
outputs:
17+
status: ${{ steps.check.outputs.status }}
18+
19+
steps:
20+
- name: 📥 Checkout
21+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22+
with:
23+
token: ${{ secrets.GITHUB_TOKEN }}
24+
persist-credentials: false
25+
26+
- name: 📦 Install dependencies
27+
run: npm ci
28+
29+
- name: 🔍 Fetch release version
30+
run: |
31+
release_version=$(npm view material-icon-theme version)
32+
current_version=$(npm list material-icon-theme --depth=0 | grep 'material-icon-theme@' | cut -d '@' -f 2)
33+
echo "release_version=$release_version" >> $GITHUB_ENV
34+
echo "current_version=$current_version" >> $GITHUB_ENV
35+
36+
- name: ❌ Check release conditions
37+
id: check
38+
run: |
39+
status="skip"
40+
if [ "$release_version" != "$current_version" ] || [ "$GITHUB_EVENT_NAME" != "schedule" ]; then
41+
status="release"
42+
fi
43+
echo "status=$status" >> $GITHUB_OUTPUT
44+
945
release:
1046
runs-on: ubuntu-latest
47+
needs: preparation
48+
if: needs.preparation.outputs.status == 'release'
1149

1250
permissions:
1351
contents: write
@@ -25,9 +63,9 @@ jobs:
2563
- name: 📥 Checkout
2664
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2765
with:
28-
# Required for fetching tags and generating release notes
2966
fetch-depth: 0
3067
token: ${{ steps.app-token.outputs.token }}
68+
persist-credentials: false
3169

3270
- name: 🔧 Configure Git
3371
run: |
@@ -38,23 +76,9 @@ jobs:
3876
- name: 📦 Install dependencies
3977
run: npm ci
4078

41-
- name: 🔍 Fetch release version
42-
id: upstream
43-
run: |
44-
release_version=$(npm view material-icon-theme version)
45-
current_version=$(npm list material-icon-theme --depth=0 | grep 'material-icon-theme@' | cut -d '@' -f 2)
46-
echo "release_version=$release_version" >> $GITHUB_ENV
47-
echo "current_version=$current_version" >> $GITHUB_ENV
48-
49-
- name: ❌ Cancel if no new release is required
50-
if: ${{ env.release_version == env.current_version && github.event_name == 'schedule' }}
51-
run: echo "No new release required. Exiting..." && exit 0
52-
5379
- name: 🔄 Attempt update
54-
if: ${{ env.release_version != env.current_version }}
5580
env:
5681
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57-
# Update the material icon theme dependency to the latest major version (to avoid breaking changes)
5882
run: |
5983
npm run update
6084
npm install [email protected]

0 commit comments

Comments
 (0)