Merge pull request #1 from GremlinLTD/feature/project-scaffolding #1
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 Candidate | |
| on: | |
| push: | |
| branches: [main] | |
| permissions: | |
| contents: write | |
| jobs: | |
| rc-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Determine version bump from commits | |
| id: bump | |
| run: | | |
| LATEST_STABLE=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1) | |
| if [ -z "$LATEST_STABLE" ]; then | |
| COMMITS=$(git log --pretty=format:"%s%n%b" HEAD) | |
| else | |
| COMMITS=$(git log --pretty=format:"%s%n%b" "${LATEST_STABLE}..HEAD") | |
| fi | |
| BUMP="patch" | |
| if echo "$COMMITS" | grep -qE '^feat(\(.+\))?!:|^fix(\(.+\))?!:|^refactor(\(.+\))?!:|^[a-z]+(\(.+\))?!:|BREAKING CHANGE:'; then | |
| BUMP="major" | |
| elif echo "$COMMITS" | grep -qE '^feat(\(.+\))?:'; then | |
| BUMP="minor" | |
| fi | |
| echo "bump=${BUMP}" >> "$GITHUB_OUTPUT" | |
| - name: Calculate next version | |
| id: version | |
| run: | | |
| LATEST_STABLE=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1) | |
| BUMP="${{ steps.bump.outputs.bump }}" | |
| if [ -z "$LATEST_STABLE" ]; then | |
| MAJOR=0; MINOR=1; PATCH=0 | |
| else | |
| VERSION="${LATEST_STABLE#v}" | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" | |
| fi | |
| case "$BUMP" in | |
| major) | |
| MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 | |
| ;; | |
| minor) | |
| MINOR=$((MINOR + 1)); PATCH=0 | |
| ;; | |
| patch) | |
| PATCH=$((PATCH + 1)) | |
| ;; | |
| esac | |
| NEXT_VERSION="${MAJOR}.${MINOR}.${PATCH}" | |
| RC_COUNT=$(git tag --sort=-v:refname | grep -cE "^v${NEXT_VERSION}-rc\." || true) | |
| RC_NUM=$((RC_COUNT + 1)) | |
| RC_TAG="v${NEXT_VERSION}-rc.${RC_NUM}" | |
| echo "tag=${RC_TAG}" >> "$GITHUB_OUTPUT" | |
| echo "version=${NEXT_VERSION}-rc.${RC_NUM}" >> "$GITHUB_OUTPUT" | |
| echo "bump=${BUMP}" >> "$GITHUB_OUTPUT" | |
| - name: Generate changelog | |
| id: changelog | |
| run: | | |
| LATEST_TAG=$(git tag --sort=-v:refname | head -1) | |
| if [ -z "$LATEST_TAG" ]; then | |
| CHANGELOG=$(git log --pretty=format:"- %s (%h)" HEAD) | |
| else | |
| CHANGELOG=$(git log --pretty=format:"- %s (%h)" "${LATEST_TAG}..HEAD") | |
| fi | |
| { | |
| echo "changelog<<EOF" | |
| echo "$CHANGELOG" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Create RC tag | |
| run: | | |
| git tag "${{ steps.version.outputs.tag }}" | |
| git push origin "${{ steps.version.outputs.tag }}" | |
| - name: Create GitHub pre-release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.tag }} | |
| name: ${{ steps.version.outputs.tag }} | |
| body: | | |
| ## Pre-release: ${{ steps.version.outputs.tag }} | |
| **Version bump**: `${{ steps.version.outputs.bump }}` (determined from conventional commits) | |
| ${{ steps.changelog.outputs.changelog }} | |
| draft: false | |
| prerelease: true |