Updates package version and type definition #4
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 | |
| jobs: | |
| check-version: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Get version | |
| id: get-version | |
| run: | | |
| VERSION=$(jq -r .version package.json) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Check tag | |
| id: check-tag | |
| run: | | |
| VERSION=${{ steps.get-version.outputs.version }} | |
| if git fetch --tags && git tag | grep -q "^v$VERSION$"; then | |
| echo "Tag v$VERSION already exists." | |
| echo "should_release=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "should_release=true" >> $GITHUB_OUTPUT | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| fi | |
| outputs: | |
| should_release: ${{ steps.check-tag.outputs.should_release }} | |
| version: ${{ steps.get-version.outputs.version }} | |
| test: | |
| runs-on: ubuntu-latest | |
| needs: check-version | |
| if: needs.check-version.outputs.should_release == 'true' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Test | |
| run: npm test | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - check-version | |
| - test | |
| permissions: | |
| contents: write | |
| if: needs.test.result == 'success' && needs.check-version.outputs.should_release == 'true' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Build | |
| run: npm run build | |
| - name: Create Tag | |
| run: | | |
| git tag v${{ needs.check-version.outputs.version }} | |
| git push origin v${{ needs.check-version.outputs.version }} | |
| - name: Create Draft Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
| tag_name: v${{ needs.check-version.outputs.version }} | |
| name: v${{ needs.check-version.outputs.version }} | |
| draft: true |