Fix deploy workflow. #9
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: Deploy Extension | |
| on: | |
| push: | |
| branches: [master] | |
| permissions: | |
| contents: write | |
| actions: read | |
| jobs: | |
| build: | |
| name: Build Extension | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: ./.github/actions/setup | |
| - run: yarn build:prod | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: extension-build | |
| path: dist/ | |
| package: | |
| name: Package Extension | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: ./.github/actions/setup | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: extension-build | |
| path: dist/ | |
| - run: yarn package:zip | |
| - name: Upload package artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: extension-package | |
| path: packages/ | |
| deploy: | |
| name: Deploy Extension | |
| runs-on: ubuntu-latest | |
| needs: [build, package] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: ./.github/actions/setup | |
| - name: Download package artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: extension-package | |
| path: packages/ | |
| - name: Deploy to Chrome Web Store | |
| run: yarn extension:deploy | |
| env: | |
| 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 }} | |
| CHROME_WEB_STORE_APP_ID: ${{ secrets.CHROME_WEB_STORE_APP_ID }} | |
| release: | |
| name: Create GitHub Release | |
| runs-on: ubuntu-latest | |
| needs: [build, package, deploy] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download package artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: extension-package | |
| path: packages/ | |
| - name: Create GitHub Release | |
| run: | | |
| VERSION=$(git describe --tags --abbrev=0) | |
| TAG_MESSAGE=$(git tag -l --format='%(contents)' "$VERSION") | |
| if [ -n "$TAG_MESSAGE" ]; then | |
| TAG_VERSION=$(echo "$TAG_MESSAGE" | head -1 | sed 's/Release //' | sed 's/^[[:space:]]*//') | |
| if [ -z "$TAG_VERSION" ] || [ "$TAG_VERSION" = "$TAG_MESSAGE" ]; then | |
| TAG_VERSION=${VERSION#v} | |
| fi | |
| CHANGELOG_ITEMS=$(echo "$TAG_MESSAGE" | grep "^-" || echo "$TAG_MESSAGE" | sed -n '/Changelog:/,//p' | grep "^-") | |
| RELEASE_NOTES="## Release $TAG_VERSION | |
| ### Changelog | |
| $CHANGELOG_ITEMS" | |
| else | |
| PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") | |
| if [ -n "$PREVIOUS_TAG" ]; then | |
| COMMITS=$(git log --oneline --pretty=format:"- %s" "$PREVIOUS_TAG..HEAD") | |
| else | |
| COMMITS=$(git log --oneline --pretty=format:"- %s") | |
| fi | |
| RELEASE_NOTES="## Release ${VERSION#v} | |
| ### Changelog | |
| $COMMITS" | |
| fi | |
| gh release create "$VERSION" packages/*.zip \ | |
| --title "${VERSION#v}" \ | |
| --notes "$RELEASE_NOTES" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |