Auto Update when upstream releases #1257
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto Update when upstream releases | |
on: | |
schedule: | |
- cron: "0 3 * * *" | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
get-version: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
- name: Install dependencies | |
run: npm ci | |
- name: Fetch release version | |
id: upstream | |
run: | | |
release_tag=$(npm view material-icon-theme version) | |
current_tag=$(npm list material-icon-theme --depth=0 | grep 'material-icon-theme@' | cut -d '@' -f 2) | |
echo "release_tag=$release_tag" >> $GITHUB_ENV | |
echo "current_tag=$current_tag" >> $GITHUB_ENV | |
- name: Attempt update | |
if: env.release_tag != env.current_tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
npm run update | |
npm i material-icon-theme@5.x | |
- name: Get package version | |
if: env.release_tag != env.current_tag | |
run: | | |
echo "package_version=v$(jq -r .version package.json)" >> $GITHUB_ENV | |
- name: Commit updated files | |
if: env.release_tag != env.current_tag | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: "." | |
message: "[auto] update to upstream ${{env.release_tag}}" | |
tag: "${{env.package_version}}" | |
- name: Release | |
if: env.release_tag != env.current_tag | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "${{env.package_version}}" | |
body: Built with icons from VSCode Material Icon Theme ${{env.release_tag}} | |
files: "*.zip" | |
generate_release_notes: true | |
- name: Upload to chrome store | |
if: env.release_tag != env.current_tag | |
continue-on-error: true | |
uses: trmcnvn/chrome-addon@v2 | |
with: | |
extension: bggfcpfjbdkhfhfmkjpbhnkhnpjjeomc | |
zip: github-material-icons-chrome-extension.zip | |
client-id: ${{ secrets.CHROME_CLIENT_ID }} | |
client-secret: ${{ secrets.CHROME_CLIENT_SECRET }} | |
refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }} | |
- name: Upload to edge store | |
if: env.release_tag != env.current_tag | |
continue-on-error: true | |
uses: wdzeng/edge-addon@v1 | |
with: | |
product-id: d7692295-d84f-4bf5-9447-3cbb6ae29517 | |
zip-path: github-material-icons-edge-extension.zip | |
client-id: ${{ secrets.EDGE_CLIENT_ID }} | |
client-secret: ${{ secrets.EDGE_CLIENT_SECRET }} | |
access-token-url: ${{ secrets.EDGE_ACCESS_TOKEN_URL }} | |
- name: Upload to firefox store | |
if: env.release_tag != env.current_tag | |
continue-on-error: true | |
run: npx web-ext sign -s ./dist/firefox/ --channel=listed --api-key=${{ secrets.FIREFOX_API_JWT_ISSUER }} --api-secret=${{ secrets.FIREFOX_API_JWT_SECRET }} |