|
| 1 | +name: Release Finalize |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + tag: |
| 7 | + description: 'Git tag to create (e.g., afm-core-v0.1.0 or ballerina-interpreter-v0.1.0)' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + implementation: |
| 11 | + description: 'Implementation directory name' |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + version: |
| 15 | + description: 'Version being released (e.g., 0.1.0)' |
| 16 | + required: true |
| 17 | + type: string |
| 18 | + branch: |
| 19 | + description: 'Branch to release from' |
| 20 | + required: true |
| 21 | + type: string |
| 22 | + is_rerelease: |
| 23 | + description: 'Whether this is a re-release' |
| 24 | + required: false |
| 25 | + default: false |
| 26 | + type: boolean |
| 27 | + |
| 28 | +jobs: |
| 29 | + finalize: |
| 30 | + runs-on: ubuntu-latest |
| 31 | + permissions: |
| 32 | + contents: write |
| 33 | + steps: |
| 34 | + - name: Checkout repository |
| 35 | + uses: actions/checkout@v4 |
| 36 | + with: |
| 37 | + ref: ${{ inputs.branch }} |
| 38 | + fetch-depth: 0 |
| 39 | + |
| 40 | + - name: Create release branch, tag, and push |
| 41 | + env: |
| 42 | + TAG: ${{ inputs.tag }} |
| 43 | + IMPLEMENTATION: ${{ inputs.implementation }} |
| 44 | + VERSION: ${{ inputs.version }} |
| 45 | + run: | |
| 46 | + git config user.name "github-actions[bot]" |
| 47 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 48 | + git checkout -b "release-${TAG%-v*}-$VERSION" |
| 49 | + git tag "$TAG" |
| 50 | + git push origin "release-${TAG%-v*}-$VERSION" |
| 51 | + git push origin "$TAG" |
| 52 | +
|
| 53 | + - name: Generate release notes |
| 54 | + env: |
| 55 | + TAG: ${{ inputs.tag }} |
| 56 | + IMPLEMENTATION: ${{ inputs.implementation }} |
| 57 | + VERSION: ${{ inputs.version }} |
| 58 | + IS_RERELEASE: ${{ inputs.is_rerelease }} |
| 59 | + run: | |
| 60 | + # Find previous tag for this implementation (exclude current version) |
| 61 | + PREV_TAG=$(git tag -l "${TAG%-v*}-v*" --sort=-v:refname | grep -v "^$TAG$" | head -1) |
| 62 | +
|
| 63 | + # Generate notes from commits that touched this implementation |
| 64 | + if [ -n "$PREV_TAG" ]; then |
| 65 | + echo "Generating notes since $PREV_TAG" |
| 66 | + COMMITS=$(git log "$PREV_TAG..HEAD" --oneline -- "$IMPLEMENTATION/" | head -50) |
| 67 | + else |
| 68 | + echo "No previous tag found, using recent commits" |
| 69 | + COMMITS=$(git log --oneline -50 -- "$IMPLEMENTATION/") |
| 70 | + fi |
| 71 | +
|
| 72 | + # Format notes |
| 73 | + RERELEASE_NOTE="" |
| 74 | + if [ "$IS_RERELEASE" = "true" ]; then |
| 75 | + RERELEASE_NOTE=" |
| 76 | +
|
| 77 | + _Re-released version_" |
| 78 | + fi |
| 79 | +
|
| 80 | + if [ -n "$COMMITS" ]; then |
| 81 | + NOTES="## Changes in $IMPLEMENTATION |
| 82 | +
|
| 83 | + $COMMITS$RERELEASE_NOTE" |
| 84 | + else |
| 85 | + NOTES="## Changes in $IMPLEMENTATION |
| 86 | +
|
| 87 | + No changes detected in this implementation directory.$RERELEASE_NOTE" |
| 88 | + fi |
| 89 | +
|
| 90 | + echo "$NOTES" > release_notes.md |
| 91 | +
|
| 92 | + - name: Create GitHub Release |
| 93 | + env: |
| 94 | + GH_TOKEN: ${{ github.token }} |
| 95 | + TAG: ${{ inputs.tag }} |
| 96 | + VERSION: ${{ inputs.version }} |
| 97 | + run: | |
| 98 | + TITLE="${TAG%-v*} v$VERSION" |
| 99 | + gh release create "$TAG" \ |
| 100 | + --title "$TITLE" \ |
| 101 | + --notes-file release_notes.md |
0 commit comments