Dev 1.5.0 as Next Stable Release #82
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: Auto Tag and Release on PR Merge | |
| on: | |
| pull_request: | |
| branches: | |
| - 'main' | |
| types: | |
| - closed | |
| permissions: | |
| contents: write | |
| jobs: | |
| tag-and-release: | |
| if: github.event.pull_request.merged == true && github.head_ref == 'dev' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| ref: 'main' # Ensure we're tagging the main branch after the merge | |
| ssh-key: ${{ secrets.DEPLOY_KEY }} | |
| - name: Configure Git | |
| run: | | |
| git config --local user.email "github-actions@github.com" | |
| git config --local user.name "GitHub Actions" | |
| - name: Determine Next Version Tag | |
| id: nextver | |
| run: | | |
| if [[ -f version.txt ]]; then | |
| NEXT_TAG=$(head -n 1 version.txt) | |
| else | |
| CURRENT_TAG=$(git tag --sort=-v:refname | head -n 1) | |
| if [[ $CURRENT_TAG == '' ]]; then | |
| CURRENT_TAG='v0.1.0' # Start from v0.1.0 if no tags are found | |
| fi | |
| MAJOR=$(echo $CURRENT_TAG | cut -d '.' -f 1 | cut -c 2-) | |
| MINOR=$(echo $CURRENT_TAG | cut -d '.' -f 2) | |
| PATCH=$(echo $CURRENT_TAG | cut -d '.' -f 3) | |
| if [[ $PATCH -eq 9 ]]; then | |
| PATCH=0 | |
| if [[ $MINOR -eq 9 ]]; then | |
| MINOR=0 | |
| MAJOR=$((MAJOR+1)) | |
| else | |
| MINOR=$((MINOR+1)) | |
| fi | |
| else | |
| PATCH=$((PATCH+1)) | |
| fi | |
| NEXT_TAG="v$MAJOR.$MINOR.$PATCH" | |
| fi | |
| echo "Next version tag: $NEXT_TAG" | |
| echo "tag=$NEXT_TAG" >> $GITHUB_OUTPUT | |
| - name: Update MerlinAU.sh Script Version and Branch | |
| run: | | |
| # Update the SCRIPT_VERSION and SCRIPT_BRANCH values in MerlinAU.sh | |
| sed -i "/^readonly SCRIPT_VERSION=/s/.*/readonly SCRIPT_VERSION=${{ steps.nextver.outputs.tag }}/" MerlinAU.sh | |
| sed -i "/^SCRIPT_BRANCH=.*$/s/.*/SCRIPT_BRANCH=\"master\"/" MerlinAU.sh | |
| - name: Stage Changes | |
| run: git add MerlinAU.sh | |
| - name: Commit Changes | |
| run: | | |
| if ! git diff --cached --quiet; then | |
| git commit -m "Update SCRIPT_BRANCH to master in MerlinAU.sh and version to ${{ steps.nextver.outputs.tag }}" | |
| else | |
| echo "No changes to commit" | |
| fi | |
| - name: Push Changes | |
| run: git push origin main | |
| - name: Create and Push Tag | |
| run: | | |
| git tag ${{ steps.nextver.outputs.tag }} | |
| git push origin ${{ steps.nextver.outputs.tag }} | |
| - name: Create Release with Automated Release Notes | |
| uses: softprops/action-gh-release@v2.3.2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| tag_name: ${{ steps.nextver.outputs.tag }} | |
| name: "Release ${{ steps.nextver.outputs.tag }}" | |
| prerelease: false | |
| generate_release_notes: true |