📦 Release - Tag, release and publish package #31
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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: 📦 Release - Tag, release and publish package | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
workflow_dispatch: | |
inputs: | |
tagName: | |
description: 'Tag name' | |
required: false | |
env: | |
node_version: 20.x | |
jobs: | |
release: | |
name: 📦 Release | |
runs-on: ubuntu-latest | |
outputs: | |
tag_name: ${{ steps.push-tag.outputs.tag_name }} | |
commit_hash: ${{ steps.push-tag.outputs.commit_hash }} | |
steps: | |
- name: ⛙ Checkout branch ${{ github.ref }} | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: 🏗️ Setup Node.js ${{ env.node_version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.node_version }} | |
cache: 'yarn' | |
- name: 🏗️ Install dependencies | |
run: | | |
# ================= 🏗️ Install dependencies ================= | |
yarn install | |
- name: 🏷️ Tag and bump Release | |
run: | | |
# ================= 🏷️ Tab and bump ================= | |
# setup git creds | |
git config user.name "GitHub Release Bot" | |
git config user.email "<>" | |
# generate release | |
yarn release | |
- name: ⛙ Push to remote | |
id: push-tag | |
run: | | |
# ================= ⛙ Push to remote ================= | |
# Check status | |
git status | |
git diff --color -U0 | cat | |
# push changes | |
git push origin --follow-tags | |
# Get tag name and commit hash | |
tag_name=$(git describe --abbrev=0 --match 'v*') | |
commit_hash=$(git rev-parse HEAD) | |
echo "Pushing tag: ${tag_name}" | |
echo "Pushing commit: ${commit_hash}" | |
# Save tag name and commit hash to output | |
echo "tag_name=${tag_name}" >> "$GITHUB_OUTPUT" | |
echo "commit_hash=${commit_hash}" >> "$GITHUB_OUTPUT" | |
publish-store: | |
needs: release | |
name: 🔌 Publish extension | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion != 'failure' }} | |
steps: | |
- name: ⛙ Checkout branch ${{ github.ref }} | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ needs.release.outputs.commit_hash || 'main' }} | |
- name: 🚧 Build | |
uses: ./.github/actions/build | |
with: | |
node_version: ${{ env.node_version }} | |
mode: extension | |
- name: 🗃️ Zip build folder | |
run: | | |
# ================= 🗃️ Zipping build folder ================= | |
# Zipping build folder for artifact upload | |
cd build; | |
zip -r synology-download.zip * | |
# Check zip created | |
echo "Zip created in 'build/'" | |
ls -l synology-download.zip | |
cd .. | |
- name: 📝 Generate Release changelog | |
run: | | |
# ================= 📝 Generate Release changelog ================= | |
yarn release:changelog | |
- name: 🏷️ Fetch latest tag | |
if: ${{ github.event.inputs.tagName == '' || needs.release.outputs.tag_name == '' }} | |
id: latest-tag | |
run: | | |
# ================= 🏷️ Fetch tags ================= | |
tag_name=$(git describe --abbrev=0 --match 'v*') | |
echo "Tag found: '$tag_name'" | |
echo "::set-output name=TAG_NAME::$tag_name" | |
- name: 📦 Push Release to github | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ github.event.inputs.tagName || needs.release.outputs.tag_name || github.ref}} | |
body_path: RELEASE.md | |
files: build/synology-download.zip | |
- name: 🔌 Publish to Chrome webstore | |
env: | |
CHROME_WEB_STORE_EXTENSION_ID: ebbdkledlkjpgbbmmopgbnnjmklnkcef | |
CHROME_WEB_STORE_CLIENT_ID: ${{ secrets.CHROME_WEB_STORE_CLIENT_ID }} | |
CHROME_WEB_STORE_CLIENT_SECRET: ${{ secrets.CHROME_WEB_STORE_CLIENT_SECRET }} | |
CHROME_WEB_STORE_REFRESH_TOKEN: ${{ secrets.CHROME_WEB_STORE_REFRESH_TOKEN }} | |
run: | | |
# ================= Publish to Chrome store ================= | |
# Uploadind zip to web store | |
yarn dlx -q chrome-webstore-upload-cli upload --source build/synology-download.zip --extension-id "$CHROME_WEB_STORE_EXTENSION_ID" --client-id "$CHROME_WEB_STORE_CLIENT_ID" --client-secret "$CHROME_WEB_STORE_CLIENT_SECRET" --refresh-token "$CHROME_WEB_STORE_REFRESH_TOKEN" | |
publish-npm: | |
needs: release | |
name: ☁️ Publish npm | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion != 'failure' }} | |
steps: | |
- name: ⛙ Checkout branch ${{ github.ref }} | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ needs.release.outputs.commit_hash || 'main' }} | |
- name: 🚧 Build | |
uses: ./.github/actions/build | |
with: | |
node_version: ${{ env.node_version }} | |
mode: web:ci | |
- name: ☁️ Publish to npm | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
# ================= ☁️ Publish to npm ================= | |
npm publish | |
- name: 💾 Caching build artefacts | |
uses: actions/cache/save@v3 | |
id: cache | |
with: | |
path: dist | |
key: ${{ github.ref }}-${{ github.run_id }}-build | |
deploy: | |
name: 🚀 Deploy | |
needs: publish-npm | |
uses: ./.github/workflows/deploy.yml | |
secrets: inherit |