Release #251
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_run: | |
| workflows: [CI] | |
| types: [completed] | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| name: Create GitHub Release | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| if: >- | |
| github.event.workflow_run.conclusion == 'success' && | |
| startsWith(github.event.workflow_run.head_branch, 'v') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_branch }} | |
| fetch-depth: 0 | |
| - name: Get version from tag | |
| id: version | |
| run: | | |
| TAG="${{ github.event.workflow_run.head_branch }}" | |
| VERSION="${TAG#v}" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| echo "Building release for version: $VERSION (tag: $TAG)" | |
| - name: Generate release notes from commits | |
| id: changelog | |
| run: | | |
| PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") | |
| echo "## What's Changed" > release-notes.md | |
| echo "" >> release-notes.md | |
| if [[ -n "$PREV_TAG" ]]; then | |
| echo "Generating changelog from $PREV_TAG to HEAD" | |
| # Categorize commits | |
| declare -A categories | |
| categories=( | |
| ["feat"]="### Features" | |
| ["fix"]="### Bug Fixes" | |
| ["docs"]="### Documentation" | |
| ["refactor"]="### Refactoring" | |
| ["test"]="### Tests" | |
| ["chore"]="### Chores" | |
| ) | |
| for prefix in feat fix docs refactor test chore; do | |
| commits=$(git log --pretty=format:"- %s (%h)" --no-merges "${PREV_TAG}..HEAD" --grep="^${prefix}:" --grep="^${prefix}(" --extended-regexp 2>/dev/null || true) | |
| if [[ -n "$commits" ]]; then | |
| echo "" >> release-notes.md | |
| echo "${categories[$prefix]}" >> release-notes.md | |
| echo "" >> release-notes.md | |
| echo "$commits" >> release-notes.md | |
| fi | |
| done | |
| # Uncategorized commits | |
| all_commits=$(git log --pretty=format:"%s" --no-merges "${PREV_TAG}..HEAD") | |
| uncategorized=$(echo "$all_commits" | grep -v -E "^(feat|fix|docs|refactor|test|chore)[:(]" || true) | |
| if [[ -n "$uncategorized" ]]; then | |
| echo "" >> release-notes.md | |
| echo "### Other Changes" >> release-notes.md | |
| echo "" >> release-notes.md | |
| echo "$uncategorized" | while read -r line; do | |
| echo "- $line" >> release-notes.md | |
| done | |
| fi | |
| else | |
| echo "### Initial Release" >> release-notes.md | |
| echo "" >> release-notes.md | |
| git log --pretty=format:"- %s (%h)" --no-merges -20 >> release-notes.md | |
| fi | |
| echo "" >> release-notes.md | |
| echo "---" >> release-notes.md | |
| echo "" >> release-notes.md | |
| echo "### Docker" >> release-notes.md | |
| echo "" >> release-notes.md | |
| echo '```bash' >> release-notes.md | |
| echo "docker pull ghcr.io/zebbern/devonz:${{ steps.version.outputs.version }}" >> release-notes.md | |
| echo '```' >> release-notes.md | |
| echo "" >> release-notes.md | |
| echo "### From Source" >> release-notes.md | |
| echo "" >> release-notes.md | |
| echo '```bash' >> release-notes.md | |
| echo "git clone https://github.com/zebbern/Devonz.git && cd Devonz" >> release-notes.md | |
| echo "git checkout v${{ steps.version.outputs.version }}" >> release-notes.md | |
| echo "pnpm install && pnpm build && pnpm start" >> release-notes.md | |
| echo '```' >> release-notes.md | |
| echo "path=release-notes.md" >> "$GITHUB_OUTPUT" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.tag }} | |
| body_path: ${{ steps.changelog.outputs.path }} | |
| generate_release_notes: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |