Release #101
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
| # yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json | |
| --- | |
| name: Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version_type: | |
| description: 'Type of version bump' | |
| required: true | |
| default: 'patch' | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| permissions: | |
| contents: write | |
| jobs: | |
| create-release: | |
| runs-on: ubuntu-latest | |
| name: Create release | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install node 24 | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: 24 | |
| cache: npm | |
| - name: Configure git | |
| run: | | |
| git config user.name "${{ github.actor }}" | |
| git config user.email "${{ github.actor }}@users.noreply.github.com" | |
| - name: Get previous released annotated tag | |
| id: last-release | |
| run: | | |
| # Get the latest tag that doesn't have -ea suffix (handles both -ea. and -ea- formats) | |
| TAG=$(git tag -l --sort=-version:refname | grep -vE -- '-ea[.-]' | head -n 1) | |
| if [ -z "$TAG" ]; then | |
| # If no release tag exists, use the base version from package.json | |
| BASE_VERSION=$(node -p "require('./package.json').version" | sed -E 's/-ea[.-][0-9]+$//') | |
| echo "base-tag=$BASE_VERSION" >> "$GITHUB_OUTPUT" | |
| echo "full-tag=$BASE_VERSION" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "base-tag=$TAG" >> "$GITHUB_OUTPUT" | |
| echo "full-tag=$TAG" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Get first tag in current development iteration | |
| id: fetch-tag | |
| run: | | |
| BASE_TAG="${{ steps.last-release.outputs.base-tag }}" | |
| # Find the oldest EA tag for this base version (handles both -ea. and -ea- formats) | |
| OLDEST_EA_TAG=$(git tag -l --sort=creatordate | grep -E "^${BASE_TAG}-ea[.-]" | head -n 1) | |
| if [ -n "$OLDEST_EA_TAG" ]; then | |
| echo "oldest-tag=$OLDEST_EA_TAG" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "oldest-tag=$BASE_TAG" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Update package with new version | |
| id: bump | |
| run: | | |
| # Get base version (remove -ea suffix if present, handles both -ea. and -ea- formats) | |
| BASE_VERSION=$(node -p "require('./package.json').version" | sed -E 's/-ea[.-][0-9]+$//') | |
| # Bump the version | |
| NEW_VERSION=$(npm version ${{ inputs.version_type }} --no-git-tag-version | sed 's/v//') | |
| echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Install project modules | |
| run: npm ci | |
| - name: Create release branch | |
| run: | | |
| BRANCH="release/v${{ steps.bump.outputs.version }}" | |
| git config user.name "${{ github.actor }}" | |
| git config user.email "${{ github.actor }}@users.noreply.github.com" | |
| git checkout -b "$BRANCH" | |
| git add package.json | |
| git add package-lock.json | |
| - name: Create Pull Request for release + next version | |
| uses: peter-evans/create-pull-request@v5 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| branch: release/v${{ steps.bump.outputs.version }} | |
| base: main | |
| title: "build: release ${{ steps.bump.outputs.version }} [skip ci]" | |
| commit-message: "build: release ${{ steps.bump.outputs.version }} [skip ci]" | |
| signoff: true | |
| - name: Create GitHub release tag | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| name: "Release ${{ steps.bump.outputs.version }}" | |
| tag_name: "v${{ steps.bump.outputs.version }}" | |
| target_commitish: "release/v${{ steps.bump.outputs.version }}" | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |