Skip to content

Commit adf9b9d

Browse files
committed
feat: update release workflow
1 parent e19b65d commit adf9b9d

File tree

5 files changed

+1329
-598
lines changed

5 files changed

+1329
-598
lines changed

.github/workflows/release.yml

+48-52
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
11
name: 🚀 Release new version
2+
23
on:
4+
schedule:
5+
- cron: "0 3 * * *" # Every day at 3:00 UTC
36
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
217

228
jobs:
239
release:
@@ -26,6 +12,7 @@ jobs:
2612
permissions:
2713
contents: write
2814
id-token: write
15+
actions: write
2916

3017
steps:
3118
- name: 🤖 Use App Token for the Bot which is allowed to create releases
@@ -38,52 +25,57 @@ jobs:
3825
- name: 📥 Checkout
3926
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4027
with:
41-
token: ${{ secrets.GITHUB_TOKEN }}
28+
token: ${{ steps.app-token.outputs.token }}
4229

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
4735
4836
- name: 📦 Install dependencies
4937
run: npm ci
5038

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
5650

5751
- name: 🔄 Attempt update
58-
if: ${{ github.event.inputs.onlyUpload == 'not' || github.event.inputs.onlyUpload == 'none' }}
52+
if: ${{ env.release_version != env.current_version }}
5953
env:
6054
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+
npm install [email protected]
7459
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
7861
env:
7962
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
8477
8578
- name: 🌐 Upload to chrome store
86-
if: ${{ github.event.inputs.onlyUpload != 'firefox' && github.event.inputs.onlyUpload != 'none' }}
8779
continue-on-error: true
8880
uses: trmcnvn/chrome-addon@7fc5a5ad3ff597dc64d6a13de7dcaa8515328be7 # v2
8981
with:
@@ -94,17 +86,21 @@ jobs:
9486
refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }}
9587

9688
- name: 🌐 Upload to edge store
97-
if: ${{ github.event.inputs.onlyUpload != 'edge' && github.event.inputs.onlyUpload != 'none' }}
9889
continue-on-error: true
9990
uses: wdzeng/edge-addon@e307af4adb6d4e1c12387dc7d6bd545dcd075909 # v1.2.5
10091
with:
101-
product-id: d7692295-d84f-4bf5-9447-3cbb6ae29517
92+
product-id: f95e9c6a-6470-45a1-ae09-821d3b916923
10293
zip-path: github-material-icons-edge-extension.zip
10394
client-id: ${{ secrets.EDGE_CLIENT_ID }}
10495
client-secret: ${{ secrets.EDGE_CLIENT_SECRET }}
10596
access-token-url: ${{ secrets.EDGE_ACCESS_TOKEN_URL }}
10697

10798
- name: 🌐 Upload to firefox store
108-
if: ${{ github.event.inputs.onlyUpload != 'chrome' && github.event.inputs.onlyUpload != 'none'}}
10999
continue-on-error: true
110100
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 }}

.github/workflows/update-from-upstream.yml

-104
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<a href="https://addons.mozilla.org/en-US/firefox/addon/material-icons-for-github/"><img src="https://github.com/material-extensions/material-icons-browser-extension/raw/main/assets/firefox-addons.png"></a>
1111
</p>
1212

13-
<b>Install directly from the <a href="https://chrome.google.com/webstore/detail/material-icons-for-github/bggfcpfjbdkhfhfmkjpbhnkhnpjjeomc">Chrome Web Store</a> | <a href="https://microsoftedge.microsoft.com/addons/detail/material-icons-for-github/khckkdgomkcjjnpgjmdmbceiddlmiolb">Microsoft Edge Addons Store</a> | <a href="https://addons.mozilla.org/en-US/firefox/addon/material-icons-for-github/">Firefox Addons</a></b></div>
13+
<b>Install directly from the <a href="https://chrome.google.com/webstore/detail/material-icons-for-github/bggfcpfjbdkhfhfmkjpbhnkhnpjjeomc">Chrome Web Store</a> | <a href="https://microsoftedge.microsoft.com/addons/detail/fmnacigfpppckhpaafbjdhljbjjclkkj">Microsoft Edge Addons Store</a> | <a href="https://addons.mozilla.org/en-US/firefox/addon/material-icons-for-github/">Firefox Addons</a></b></div>
1414

1515
---
1616

0 commit comments

Comments
 (0)