Build and Release #3165
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 | |
| permissions: | |
| contents: write | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 */1 * * *' | |
| jobs: | |
| build: | |
| if: | | |
| github.event_name == 'workflow_dispatch' || | |
| (github.event_name == 'schedule' && github.ref == 'refs/heads/main') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out the code | |
| uses: actions/checkout@v4 | |
| - name: Get release version | |
| id: get_version | |
| run: echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT | |
| - name: Check release version | |
| run: echo "Release version is ${{ steps.get_version.outputs.version }}" | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "latest" | |
| - name: Install dependencies | |
| run: npm install --production | |
| - name: Type check | |
| run: npm run check | |
| - name: Build project | |
| run: npm run build | |
| - name: Read release note | |
| id: read_release | |
| shell: bash | |
| run: | | |
| r=$(cat RELEASE.md) | |
| r="${r//'%'/'%25'}" | |
| r="${r//$'\n'/'%0A'}" | |
| r="${r//$'\r'/'%0D'}" | |
| echo "RELEASE_BODY=$r" >> $GITHUB_OUTPUT | |
| - name: Upload Release Assets | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: dist/* | |
| tag: v${{ steps.get_version.outputs.version }} | |
| release_name: Release v${{ steps.get_version.outputs.version }} | |
| overwrite: true | |
| file_glob: true | |
| prerelease: ${{ github.ref != 'refs/heads/main' }} | |
| promote: ${{ github.ref == 'refs/heads/main' }} | |
| make_latest: ${{ github.ref == 'refs/heads/main' }} | |
| body: ${{ steps.read_release.outputs.RELEASE_BODY }} |