Manual Release #37
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: Manual Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Version number (e.g., v0.2.1). If not provided, it will be auto-incremented." | |
| required: false | |
| default: "" | |
| permissions: write-all | |
| jobs: | |
| create_release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Determine Version | |
| id: version | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # If user provided a version, use it | |
| if [ "${{ github.event.inputs.version }}" != "" ]; then | |
| echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # Fetch the latest release tag | |
| LATEST_TAG=$(gh release view --json tagName --jq .tagName) | |
| # Parse the version string: v<major>.<minor>.<patch> | |
| # Assuming tags follow semantic versioning pattern like v0.2.0 | |
| MAJOR=$(echo $LATEST_TAG | sed 's/v\([0-9]*\)\..*/\1/') | |
| MINOR=$(echo $LATEST_TAG | sed 's/v[0-9]*\.\([0-9]*\).*/\1/') | |
| PATCH=$(echo $LATEST_TAG | sed 's/v[0-9]*\.[0-9]*\.\([0-9]*\).*/\1/') | |
| # Increment the patch number by 1 | |
| PATCH=$((PATCH+1)) | |
| NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}" | |
| echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release create ${{ steps.version.outputs.version }} \ | |
| --repo="$GITHUB_REPOSITORY" \ | |
| --title="${{ steps.version.outputs.version }}" \ | |
| --generate-notes | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| registry-url: 'https://registry.npmjs.org/' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Update version in package.json | |
| run: npm version $(echo ${{ steps.version.outputs.version }} | sed 's/^v//') --no-git-tag-version | |
| - name: Publish to NPM | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |