chore(release): 4.0.4 #13
Workflow file for this run
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: Publish Release | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| branches: | |
| - master | |
| - staging | |
| permissions: | |
| contents: write | |
| jobs: | |
| publish-release: | |
| name: Create GitHub Release | |
| runs-on: ubuntu-latest | |
| # Run only if merged AND has 'release' label | |
| if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release') | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Create Release and Tag | |
| id: create_release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # 1. Extract Version | |
| VERSION=$(grep "^GLOBAL_VERSION_NAME=" gradle.properties | cut -d'=' -f2) | |
| if [ -z "$VERSION" ]; then | |
| echo "Error: Could not detect version from gradle.properties." | |
| exit 1 | |
| fi | |
| echo "Detected Version: $VERSION" | |
| TAG_NAME="v$VERSION" | |
| # Output for next steps | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| # 2. Create the GitHub Release | |
| gh release create "$TAG_NAME" \ | |
| --title "$TAG_NAME" \ | |
| --notes "Automated release for version $TAG_NAME. See CHANGELOG.md for details." \ | |
| --target ${{ github.base_ref }} | |
| - name: Delete release branch | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION="${{ steps.create_release.outputs.version }}" | |
| RELEASE_BRANCH="release/${VERSION}" | |
| # Check if branch exists before deleting | |
| if git ls-remote --exit-code --heads origin "$RELEASE_BRANCH" >/dev/null 2>&1; then | |
| echo "Deleting release branch: $RELEASE_BRANCH" | |
| git push origin --delete "$RELEASE_BRANCH" | |
| else | |
| echo "Release branch $RELEASE_BRANCH already deleted." | |
| fi |