feat: add GitHub Actions workflow for build and release process #1
Workflow file for this run
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: Build and Release | |
| on: | |
| push: | |
| tags: | |
| - '*' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout the repository | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # Setup Node.js | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| # Install dependencies | |
| - name: Install dependencies | |
| run: pnpm install | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Extract version from package.json | |
| - name: Get version from package.json | |
| id: get_version | |
| run: | | |
| echo "VERSION=$(jq -r .version package.json)" >> $GITHUB_ENV | |
| # Run the build commands | |
| - name: Build .zip files | |
| run: | | |
| pnpm zip | |
| pnpm zip:firefox | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout the repository | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # Create a GitHub release | |
| - name: Create Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| release_name: Release ${{ github.ref_name }} | |
| draft: false | |
| prerelease: false | |
| body: | | |
| This is the release for version ${{ env.VERSION }}. | |
| # Upload Chrome release asset | |
| - name: Upload Chrome release asset | |
| uses: actions/upload-release-asset@v1 | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ./out/wechat-reader-enhancer-${{ env.VERSION }}-chrome.zip | |
| asset_name: wechat-reader-enhancer-${{ env.VERSION }}-chrome.zip | |
| asset_content_type: application/zip | |
| # Upload Firefox release asset | |
| - name: Upload Firefox release asset | |
| uses: actions/upload-release-asset@v1 | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ./out/wechat-reader-enhancer-${{ env.VERSION }}-firefox.zip | |
| asset_name: wechat-reader-enhancer-${{ env.VERSION }}-firefox.zip | |
| asset_content_type: application/zip |