Skip to content

Create new release

Create new release #83

name: Create new release
on:
workflow_dispatch:
inputs:
new_version:
description: 'New version'
required: true
type: string
jobs:
set-new-version:
runs-on: ubuntu-latest
outputs:
commit_hash: ${{steps.commit_new_version.outputs.commit_hash}}
steps:
- uses: actions/checkout@v4
- name: Set new version format
working-directory: ./apps/webextension/
run: |
if [[ "${{ inputs.new_version }}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]];
then
echo "New version looks okay";
MAJOR="${BASH_REMATCH[1]}"
MINOR="${BASH_REMATCH[2]}"
PATCH="${BASH_REMATCH[3]}"
sed -r -i "s/\"version\": *\"[0-9]+\\.[0-9]+\\.[0-9]+\"/\"version\": \"$MAJOR.$MINOR.$PATCH\"/g" package.json
else
echo "Invalid version format";
exit 1
fi
- id: commit_new_version
uses: stefanzweifel/[email protected]
with:
commit_message: "chore: Updated version"
push_options: '--force'
create-release:
runs-on: ubuntu-latest
needs: set-new-version
outputs:
upload_url: ${{steps.create-release.outputs.upload_url}}
steps:
- uses: actions/checkout@v4
with:
ref: "${{needs.set-new-version.outputs.commit_hash}}"
fetch-depth: 0
- id: create-release
uses: ncipollo/[email protected]
with:
bodyFile: ".github/release-body.md"
artifactErrorsFailBuild: true
updateOnlyUnreleased: true
allowUpdates: true
removeArtifacts: true
draft: true
tag: "v${{ inputs.new_version }}"
commit: "${{needs.set-new-version.outputs.commit_hash}}"
build:
runs-on: ubuntu-latest
environment: webextension
needs: [set-new-version, create-release]
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
PUBLIC_FLICKR_API_KEY: ${{secrets.PUBLIC_FLICKR_API_KEY}}
PRIVATE_CORS_BYPASS: ${{secrets.PRIVATE_CORS_BYPASS}}
VITE_OWM_REDIRECT: ${{secrets.VITE_OWM_REDIRECT}}
VITE_IQA_REDIRECT: ${{secrets.VITE_IQA_REDIRECT}}
PUBLIC_THEQUOTEAPI_KEY: ${{secrets.PUBLIC_THEQUOTEAPI_KEY}}
PUBLIC_NASA_APOD_API_KEY: ${{secrets.PUBLIC_NASA_APOD_API_KEY}}
PUBLIC_PEXELS_API_KEY: ${{secrets.PUBLIC_PEXELS_API_KEY}}
VITE_CORS_BYPASS: ${{secrets.VITE_CORS_BYPASS}}
PUBLIC_REALFAVICON_API_KEY: ${{secrets.PUBLIC_REALFAVICON_API_KEY}}
PUBLIC_CLOUDIMG_TOKEN: ${{secrets.PUBLIC_CLOUDIMG_TOKEN}}
steps:
- uses: actions/checkout@v4
with:
ref: "${{needs.set-new-version.outputs.commit_hash}}"
fetch-depth: 0
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: ./.nvmrc
- name: Set generate external assets CDN
run: |
echo "PUBLIC_EXTERNAL_ASSETS_URI=${{secrets.PUBLIC_EXTERNAL_ASSETS_URI}}" >> $GITHUB_ENV
- uses: pnpm/[email protected]
name: Install pnpm
with:
run_install: false
- name: Install dependencies
run: |
sudo apt-get install -y rename
pnpm install -r --frozen-lockfile
- name: Build
run: |
pnpm nx build webextension
pnpm nx build:web-ext:firefox webextension
pnpm nx build:web-ext:chromium webextension
rename 's/sveltab-/sveltab-chromium-/' ./apps/webextension/build-web-ext/chromium/sveltab-*.zip
rename 's/sveltab-/sveltab-firefox-/' ./apps/webextension/build-web-ext/firefox/sveltab-*.zip
find ./apps/webextension/build-web-ext -type f -mindepth 1 -exec cp '{}' ./apps/webextension/build-web-ext \;
- uses: actions/upload-artifact@v4
with:
name: release
compression-level: 0
path: |
./apps/webextension/build-web-ext/sveltab-*.zip
- name: Upload Release Asset
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./apps/webextension/build-web-ext/sveltab-*.zip
checksum:
runs-on: ubuntu-latest
needs: ['create-release', 'build']
steps:
- name: Download release artifacts
uses: actions/download-artifact@v4
with:
name: release
path: release
merge-multiple: true
- name: Generate checksum
run: |
cd release
find . -type f -maxdepth 1 -exec sha256sum {} \; > ../checksum.txt
- name: Upload Release Asset
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: checksum.txt
publish-mozilla:
runs-on: ubuntu-latest
needs: ['build']
environment: store-mozilla
steps:
- name: Download release artifacts
uses: actions/download-artifact@v4
with:
name: release
path: release
- name: Get addon file path
run: |
cd release
echo "ADDON_FILE=$(find $(pwd) -type f -maxdepth 1 -name 'sveltab-firefox-*.zip')" >> $GITHUB_OUTPUT
id: find_addon_file
- uses: wdzeng/firefox-addon@v1
name: Publish to Mozilla Addons Store
with:
addon-guid: ${{ secrets.ADDON_GUID }}
xpi-path: ${{ steps.find_addon_file.outputs.ADDON_FILE }}
self-hosted: false
jwt-issuer: ${{ secrets.JWT_ISSUER }}
jwt-secret: ${{ secrets.JWT_SECRET }}
publish-chrome-store:
runs-on: ubuntu-latest
needs: ['build']
environment: chrome-store
steps:
- name: Download release artifacts
uses: actions/download-artifact@v4
with:
name: release
path: release
- name: Get addon file path
run: |
cd release
echo "ADDON_FILE=$(find $(pwd) -type f -maxdepth 1 -name 'sveltab-chromium-*.zip')" >> $GITHUB_OUTPUT
id: find_addon_file
- uses: wdzeng/chrome-extension@v1
with:
extension-id: ${{ secrets.EXTENSION_ID }}
zip-path: ${{ steps.find_addon_file.outputs.ADDON_FILE }}
client-id: ${{ secrets.CLIENT_ID }}
client-secret: ${{ secrets.CLIENT_SECRET }}
refresh-token: ${{ secrets.REFRESH_TOKEN }}
publish-edge-store:
runs-on: ubuntu-latest
needs: ['build']
environment: store-edge
steps:
- name: Download release artifacts
uses: actions/download-artifact@v4
with:
name: release
path: release
- name: Get addon file path
run: |
cd release
echo "ADDON_FILE=$(find $(pwd) -type f -maxdepth 1 -name 'sveltab-chromium-*.zip')" >> $GITHUB_OUTPUT
id: find_addon_file
- uses: wdzeng/edge-addon@v1
with:
product-id: ${{ secrets.PRODUCT_ID }}
zip-path: ${{ steps.find_addon_file.outputs.ADDON_FILE }}
client-id: ${{ secrets.CLIENT_ID }}
client-secret: ${{ secrets.CLIENT_SECRET }}
access-token-url: ${{ secrets.ACCESS_TOKEN_URL }}