Release #7
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: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to release (leave empty for patch bump)' | |
| required: false | |
| default: '' | |
| bump: | |
| description: 'Version bump type (if version not specified)' | |
| required: false | |
| type: choice | |
| default: 'patch' | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| dry_run: | |
| description: 'Dry run (skip publish & tag)' | |
| required: false | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| id-token: write | |
| concurrency: | |
| group: release | |
| cancel-in-progress: false | |
| env: | |
| NODE_VERSION: '22' | |
| PNPM_VERSION: '10' | |
| jobs: | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: '◆ Checkout' | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: '◇ Setup pnpm' | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: ${{ env.PNPM_VERSION }} | |
| - name: '◇ Setup Node.js' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'pnpm' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: '◇ Configure git' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: '△ Determine version' | |
| id: version | |
| run: | | |
| if [[ -n "${{ inputs.version }}" ]]; then | |
| VERSION="${{ inputs.version }}" | |
| else | |
| CURRENT=$(node -p "require('./package.json').version") | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "${CURRENT%%-*}" | |
| case "${{ inputs.bump }}" in | |
| major) VERSION="$((MAJOR + 1)).0.0" ;; | |
| minor) VERSION="${MAJOR}.$((MINOR + 1)).0" ;; | |
| patch) VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))" ;; | |
| esac | |
| fi | |
| if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then | |
| echo "::error::Invalid version format: $VERSION" | |
| exit 1 | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Releasing version: $VERSION" | |
| - name: '△ Update version → ${{ steps.version.outputs.version }}' | |
| run: | | |
| npm version ${{ steps.version.outputs.version }} --no-git-tag-version --allow-same-version | |
| - name: '◈ Install dependencies' | |
| run: pnpm install --frozen-lockfile | |
| - name: '▲ Build' | |
| run: pnpm build | |
| - name: '● Run tests' | |
| run: pnpm test | |
| - name: '● Run integration tests' | |
| run: pnpm test:integration | |
| - name: '◆ Commit version bump' | |
| if: ${{ !inputs.dry_run }} | |
| run: | | |
| git add package.json | |
| git commit -m "🔖 v${{ steps.version.outputs.version }}" | |
| - name: '◆ Create and push tag' | |
| if: ${{ !inputs.dry_run }} | |
| run: | | |
| git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}" | |
| git push origin HEAD:${{ github.ref_name }} | |
| git push origin "v${{ steps.version.outputs.version }}" | |
| - name: '▲ Publish to npm' | |
| if: ${{ !inputs.dry_run }} | |
| run: pnpm publish --access public --no-git-checks | |
| - name: '◆ Create GitHub Release' | |
| if: ${{ !inputs.dry_run }} | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| generate_release_notes: true | |
| - name: '► Summary' | |
| run: | | |
| echo "## Release ${{ inputs.dry_run && '[DRY RUN] ' || '' }}v${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [[ "${{ inputs.dry_run }}" == "true" ]]; then | |
| echo "✓ Build and tests passed. Ready to release." >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "✓ Successfully released" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "- [npm](https://www.npmjs.com/package/next-dynenv/v/${{ steps.version.outputs.version }})" >> $GITHUB_STEP_SUMMARY | |
| echo "- [GitHub Release](https://github.com/${{ github.repository }}/releases/tag/v${{ steps.version.outputs.version }})" >> $GITHUB_STEP_SUMMARY | |
| fi |