1
1
name : 🚀 Release new version
2
+
2
3
on :
4
+ schedule :
5
+ - cron : " 0 3 * * *" # Every day at 3:00 UTC
3
6
workflow_dispatch :
4
- inputs :
5
- versionChange :
6
- type : choice
7
- description : Select the version change
8
- required : true
9
- default : ' patch'
10
- options :
11
- - major
12
- - minor
13
- - patch
14
- onlyUpload :
15
- description : chrome|firefox|both|not|none - Only upload to store(s) without bumping version or releasing
16
- required : true
17
- default : not
18
-
19
- permissions :
20
- contents : read
21
7
22
8
jobs :
23
9
release :
26
12
permissions :
27
13
contents : write
28
14
id-token : write
15
+ actions : write
29
16
30
17
steps :
31
18
- name : 🤖 Use App Token for the Bot which is allowed to create releases
@@ -38,52 +25,57 @@ jobs:
38
25
- name : 📥 Checkout
39
26
uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
40
27
with :
41
- token : ${{ secrets.GITHUB_TOKEN }}
28
+ token : ${{ steps.app-token.outputs.token }}
42
29
43
- - name : 🛠️ Setup Node
44
- uses : actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
45
- with :
46
- node-version : " 20"
30
+ - name : 🔧 Configure Git
31
+ run : |
32
+ git config user.name 'github-actions[bot]'
33
+ git config user.email 'github-actions[bot]@users.noreply.github.com'
34
+ git config --global push.followTags true
47
35
48
36
- name : 📦 Install dependencies
49
37
run : npm ci
50
38
51
- - name : 🏗️ Build extension
52
- if : ${{ github.event.inputs.onlyUpload != 'not' && github.event.inputs.onlyUpload != 'none' }}
53
- env :
54
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
55
- run : npm run build
39
+ - name : 🔍 Fetch release version
40
+ id : upstream
41
+ run : |
42
+ release_version=$(npm view material-icon-theme version)
43
+ current_version=$(npm list material-icon-theme --depth=0 | grep 'material-icon-theme@' | cut -d '@' -f 2)
44
+ echo "release_version=$release_version" >> $GITHUB_ENV
45
+ echo "current_version=$current_version" >> $GITHUB_ENV
46
+
47
+ - name : ❌ Cancel if no new release is required
48
+ if : ${{ env.release_version == env.current_version && github.event_name == 'schedule' }}
49
+ run : echo "No new release required. Exiting..." && exit 0
56
50
57
51
- name : 🔄 Attempt update
58
- if : ${{ github.event.inputs.onlyUpload == 'not' || github.event.inputs.onlyUpload == 'none' }}
52
+ if : ${{ env.release_version != env.current_version }}
59
53
env :
60
54
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
61
- run : npm run release ${{ github.event.inputs.versionChange }}
62
-
63
- - name : 📝 Get package version
64
- if : ${{ github.event.inputs.onlyUpload == 'not' || github.event.inputs.onlyUpload == 'none' }}
65
- run : echo "package_version=v$(jq -r .version package.json)" >> $GITHUB_ENV
66
-
67
- - name : 💾 Commit updated files
68
- if : ${{ github.event.inputs.onlyUpload == 'not' || github.event.inputs.onlyUpload == 'none' }}
69
- uses : EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4
70
- with :
71
- add : " ."
72
- message : " [auto] release ${{env.package_version}}"
73
- tag : " ${{env.package_version}}"
55
+ # Update the material icon theme dependency to the latest major version (to avoid breaking changes)
56
+ run : |
57
+ npm run update
58
+
74
59
75
- - name : 🚀 Release
76
- if : ${{ github.event.inputs.onlyUpload == 'not' || github.event.inputs.onlyUpload == 'none' }}
77
- uses : softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1
60
+ - name : 🏗️ Build extension
78
61
env :
79
62
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
80
- with :
81
- tag_name : " ${{env.package_version}}"
82
- files : " *.zip"
83
- generate_release_notes : true
63
+ run : npm run build
64
+
65
+ - name : 📜 Generate changelog and release notes
66
+ env :
67
+ # Don't run husky on `git commit`
68
+ HUSKY : 0
69
+ run : |
70
+ npx changelogen --hideAuthorEmail --release --push
71
+ npx changelogen github release --token ${{ secrets.GITHUB_TOKEN }}
72
+
73
+ - name : 📝 Get metadata
74
+ run : |
75
+ VERSION=$(jq -r '.version' package.json)
76
+ echo "VERSION=$VERSION" >> $GITHUB_ENV
84
77
85
78
- name : 🌐 Upload to chrome store
86
- if : ${{ github.event.inputs.onlyUpload != 'firefox' && github.event.inputs.onlyUpload != 'none' }}
87
79
continue-on-error : true
88
80
uses : trmcnvn/chrome-addon@7fc5a5ad3ff597dc64d6a13de7dcaa8515328be7 # v2
89
81
with :
@@ -94,17 +86,21 @@ jobs:
94
86
refresh-token : ${{ secrets.CHROME_REFRESH_TOKEN }}
95
87
96
88
- name : 🌐 Upload to edge store
97
- if : ${{ github.event.inputs.onlyUpload != 'edge' && github.event.inputs.onlyUpload != 'none' }}
98
89
continue-on-error : true
99
90
uses : wdzeng/edge-addon@e307af4adb6d4e1c12387dc7d6bd545dcd075909 # v1.2.5
100
91
with :
101
- product-id : d7692295-d84f-4bf5-9447-3cbb6ae29517
92
+ product-id : f95e9c6a-6470-45a1-ae09-821d3b916923
102
93
zip-path : github-material-icons-edge-extension.zip
103
94
client-id : ${{ secrets.EDGE_CLIENT_ID }}
104
95
client-secret : ${{ secrets.EDGE_CLIENT_SECRET }}
105
96
access-token-url : ${{ secrets.EDGE_ACCESS_TOKEN_URL }}
106
97
107
98
- name : 🌐 Upload to firefox store
108
- if : ${{ github.event.inputs.onlyUpload != 'chrome' && github.event.inputs.onlyUpload != 'none'}}
109
99
continue-on-error : true
110
100
run : npx web-ext sign -s ./dist/firefox/ --channel=listed --api-key=${{ secrets.FIREFOX_API_JWT_ISSUER }} --api-secret=${{ secrets.FIREFOX_API_JWT_SECRET }}
101
+
102
+ - name : ⬆️ Upload zip files to GitHub release
103
+ run : |
104
+ gh release upload v$VERSION github-material-icons-chrome-extension.zip github-material-icons-edge-extension.zip github-material-icons-firefox-extension.zip
105
+ env :
106
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments