Release #360
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_bump: | |
| required: true | |
| description: 'Version bump type' | |
| type: choice | |
| options: | |
| - major | |
| - minor | |
| jobs: | |
| release_pr: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'npm' | |
| - name: Fetch files and ensure branches exist | |
| run: | | |
| git fetch origin | |
| if [ -f .git/shallow ]; then | |
| echo "Shallow repo clone, unshallowing" | |
| git fetch --unshallow | |
| fi | |
| git fetch --tags | |
| # Check if the 'main' branch exists, if not, create it | |
| if git rev-parse --verify main >/dev/null 2>&1; then | |
| git checkout main | |
| else | |
| git checkout -b main origin/main | |
| fi | |
| # Check if the 'releases' branch exists, if not, create it | |
| if git rev-parse --verify releases >/dev/null 2>&1; then | |
| git checkout releases | |
| else | |
| git checkout -b releases origin/releases | |
| fi | |
| - name: Calculate next version | |
| id: version | |
| run: | | |
| # Get the latest tag (no longer using v prefix, filter out legacy v-prefixed tags) | |
| LATEST_TAG=$(git tag | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1) | |
| # Stop build if no version tag is found | |
| if [ -z "$LATEST_TAG" ]; then | |
| echo "Error: No semantic version tags found in repository" | |
| echo "Expected format: X.Y.Z (e.g., 12.5.0)" | |
| exit 1 | |
| fi | |
| echo "Latest tag found: $LATEST_TAG" | |
| # Extract version numbers (remove 'v' prefix if present for backwards compatibility) | |
| VERSION_WITHOUT_V=${LATEST_TAG#v} | |
| # Parse major and minor (ignore patch since we don't support it) | |
| MAJOR=$(echo $VERSION_WITHOUT_V | cut -d. -f1) | |
| MINOR=$(echo $VERSION_WITHOUT_V | cut -d. -f2) | |
| # Calculate next version based on input | |
| if [ "${{ github.event.inputs.version_bump }}" = "major" ]; then | |
| NEXT_MAJOR=$((MAJOR + 1)) | |
| NEXT_MINOR=0 | |
| else | |
| NEXT_MAJOR=$MAJOR | |
| NEXT_MINOR=$((MINOR + 1)) | |
| fi | |
| # Create new version (always without v prefix) | |
| NEXT_VERSION="${NEXT_MAJOR}.${NEXT_MINOR}.0" | |
| echo "Next version: $NEXT_VERSION" | |
| echo "RELEASE_VERSION=$NEXT_VERSION" >> $GITHUB_ENV | |
| echo "version=$NEXT_VERSION" >> $GITHUB_OUTPUT | |
| - name: Collect commit ranges | |
| run: | | |
| bash ./scripts/changelog.sh > ${{ github.workspace }}/CHANGELOG.txt | |
| - name: Debug changelog file | |
| run: | | |
| ls -la ${{ github.workspace }}/CHANGELOG.txt | |
| cat ${{ github.workspace }}/CHANGELOG.txt | |
| echo "Current tag is: $(git rev-list --tags --max-count=1)" | |
| - name: Ensure clean release branch from main | |
| run: | | |
| # Remove all tracked and untracked files except .git and .github | |
| find . -mindepth 1 -maxdepth 1 ! -name '.git' ! -name '.github' ! -name 'CHANGELOG.txt' -exec rm -rf {} + | |
| # Copy files from main branch | |
| git checkout main -- . | |
| - name: Build release | |
| run: | | |
| npm ci | |
| npm run build | |
| - name: Check in files | |
| run: | | |
| git add -f . ':!CHANGELOG.txt' ':!node_modules' | |
| - name: Commit build files | |
| uses: stefanzweifel/git-auto-commit-action@v7 | |
| with: | |
| commit_message: 'Release build ${{ steps.version.outputs.version }} [ci release]' | |
| commit_options: '--allow-empty' | |
| skip_checkout: true | |
| branch: 'releases' | |
| - name: Debug changelog file | |
| run: | | |
| ls -la ${{ github.workspace }}/CHANGELOG.txt | |
| cat ${{ github.workspace }}/CHANGELOG.txt | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| body_path: ${{ github.workspace }}/CHANGELOG.txt | |
| draft: false | |
| prerelease: false | |
| tag_name: ${{ steps.version.outputs.version }} | |
| target_commitish: 'releases' |