release #157
This file contains hidden or 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: release | |
| on: | |
| workflow_dispatch: | |
| push: | |
| tags: | |
| - "v*" | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.sha }} | |
| permissions: | |
| contents: write | |
| jobs: | |
| setup: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag: ${{ steps.get-tag.outputs.tag }} | |
| version: ${{ steps.get-version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # get the current draft release | |
| - id: get-tag | |
| name: get tag | |
| run: | | |
| echo "tag=$(gh api /repos/ethui/extension/releases |\ | |
| jq -r '[.[] | select(.draft == true)][0] | .tag_name')" \ | |
| >> $GITHUB_OUTPUT | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # get the current version (tag without the `v`) | |
| - id: get-version | |
| name: get version | |
| run: | | |
| version=$(echo ${{ steps.get-tag.outputs.tag }} | sed 's/^v//') | |
| echo "version=$version" >> $GITHUB_OUTPUT | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # deletes all assets previously uploaded to the current draft release | |
| # necessary if we have to retry a release build due to a prior failure | |
| clear-assets: | |
| needs: [setup] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: | | |
| for name in $(gh release view ${{needs.setup.outputs.tag}} --json assets | jq -r '.assets[].name'); do | |
| gh release delete-asset ${{needs.setup.outputs.tag}} $name | |
| done | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish: | |
| needs: [setup, clear-assets] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: corepack enable yarn | |
| - uses: actions/setup-node@v4 | |
| with: | |
| cache: "yarn" | |
| node-version: "22" | |
| - run: yarn install --immutable | |
| - run: yarn build --target chrome -v ${{ needs.setup.outputs.version }} | |
| - run: yarn build --target firefox -v ${{ needs.setup.outputs.version }} | |
| - name: Upload to Draft Release | |
| run: gh release upload ${{ needs.setup.outputs.tag }} ./dist/*.{crx,xpi} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Submit to Google | |
| run: npx chrome-webstore-upload-cli@3 upload --source ./dist/chrome --auto-publish | |
| continue-on-error: true | |
| env: | |
| EXTENSION_ID: ${{ secrets.GOOGLE_EXT_EXTENSION_ID }} | |
| CLIENT_ID: ${{ secrets.GOOGLE_EXT_CLIENT_ID }} | |
| CLIENT_SECRET: ${{ secrets.GOOGLE_EXT_CLIENT_SECRET }} | |
| REFRESH_TOKEN: ${{ secrets.GOOGLE_EXT_REFRESH_TOKEN }} | |
| - name: Submit to Mozilla | |
| run: yarn run web-ext sign --channel listed --source-dir ./dist/firefox | |
| env: | |
| WEB_EXT_API_KEY: ${{ secrets.MOZILLA_WEB_EXT_API_KEY }} | |
| WEB_EXT_API_SECRET: ${{ secrets.MOZILLA_WEB_EXT_API_SECRET }} | |
| publish-release: | |
| needs: [setup, publish] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: publish release | |
| run: gh release edit ${{ needs.setup.outputs.tag }} --draft=false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |