chore(release): v0.3.10 (#184) #144
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: | |
| push: | |
| branches: | |
| - main | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| release: | |
| if: startsWith(github.event.head_commit.message, 'chore(release):') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-node@v7 | |
| with: | |
| node-version-file: ".nvmrc" | |
| registry-url: "https://registry.npmjs.org" | |
| package-manager-cache: false | |
| - name: Install dependencies | |
| run: | | |
| npm ci | |
| - name: Build project | |
| run: | | |
| npm run build | |
| - name: Package prebuilts | |
| run: | | |
| tar -czf prebuilts.tar.gz -C css/prebuilt . | |
| - name: Configure git | |
| run: | | |
| git config user.name "${{ github.actor }}" | |
| git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" | |
| - name: Parse version number | |
| id: parse_version | |
| run: | | |
| COMMIT_MESSAGE=$(echo "${{ github.event.head_commit.message }}" | head -n 1) | |
| VERSION=$(echo "$COMMIT_MESSAGE" | sed -n 's/^chore(release): *\([^ \n]*\).*/\1/p') | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Create and push tag | |
| run: | | |
| VERSION="${{ steps.parse_version.outputs.version }}" | |
| git tag "$VERSION" | |
| git push origin "$VERSION" | |
| - name: Create GitHub app token | |
| id: generate_token | |
| uses: actions/create-github-app-token@v3.2.0 | |
| with: | |
| app-id: ${{ secrets.CARBON_AUTOMATION_APP_ID }} | |
| private-key: ${{ secrets.CARBON_AUTOMATION_APP_PRIVATE_KEY }} | |
| - name: Create GitHub release | |
| uses: actions/github-script@v9 | |
| with: | |
| github-token: ${{ steps.generate_token.outputs.token }} | |
| script: | | |
| const fs = require('fs'); | |
| const { owner, repo } = context.repo; | |
| const version = '${{ steps.parse_version.outputs.VERSION }}'; | |
| const release = await github.rest.repos.createRelease({ | |
| owner, | |
| repo, | |
| tag_name: version, | |
| name: version, | |
| prerelease: version.includes('-'), | |
| generate_release_notes: true, | |
| }); | |
| await github.rest.repos.uploadReleaseAsset({ | |
| owner, | |
| repo, | |
| release_id: release.data.id, | |
| name: 'prebuilts.tar.gz', | |
| data: fs.readFileSync('./prebuilts.tar.gz'), | |
| }); | |
| - name: Create npm release | |
| run: | | |
| TAG=$(echo "${{ steps.parse_version.outputs.version }}" | grep -q '-' && echo "next" || echo "latest") | |
| npm publish --tag $TAG | |
| publish-cdn: | |
| needs: release | |
| uses: ./.github/workflows/cdn.yml | |
| secrets: inherit | |
| deploy-docs: | |
| needs: release | |
| uses: ./.github/workflows/deploy-docs.yml |