Create Release on Tag Push #3
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: Create Release with Manual Tag | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| workflow_dispatch: | |
| inputs: | |
| tag_name: | |
| description: 'Tag name for the release (e.g., v6.09.08 for production, v6.09.08-SNAPSHOT for nightly, v6.09.08.RC1 for release candidate). Must already exist.' | |
| required: true | |
| type: string | |
| prerelease: | |
| description: 'Mark as a pre-release (use for nightly builds and RCs)' | |
| required: false | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| jobs: | |
| create_release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ inputs.tag_name || github.ref }} | |
| - name: Validate tag matches gradle.properties version | |
| run: | | |
| TAG_NAME="${{ inputs.tag_name || github.ref_name }}" | |
| GRADLE_VERSION=$(grep '^version=' gradle.properties | head -1 | cut -d'=' -f2 | tr -d '[:space:]') | |
| EXPECTED_TAG="v${GRADLE_VERSION}" | |
| echo "Tag name: ${TAG_NAME}" | |
| echo "gradle.properties version: ${GRADLE_VERSION}" | |
| echo "Expected tag: ${EXPECTED_TAG}" | |
| echo "" | |
| if [ "${TAG_NAME}" != "${EXPECTED_TAG}" ]; then | |
| echo "::error::Tag '${TAG_NAME}' does not match gradle.properties version '${GRADLE_VERSION}'." | |
| echo "" | |
| echo "=========================================" | |
| echo " HOW TO FIX" | |
| echo "=========================================" | |
| echo "" | |
| echo "Option 1: Update gradle.properties to match the tag" | |
| echo " - Edit gradle.properties and set: version=${TAG_NAME#v}" | |
| echo " - Commit, push, then re-tag:" | |
| echo " git tag -d ${TAG_NAME}" | |
| echo " git push origin :refs/tags/${TAG_NAME}" | |
| echo " git tag ${TAG_NAME}" | |
| echo " git push origin ${TAG_NAME}" | |
| echo "" | |
| echo "Option 2: Create the correct tag for the current version" | |
| echo " - git tag ${EXPECTED_TAG}" | |
| echo " - git push origin ${EXPECTED_TAG}" | |
| echo " - Then trigger this workflow with tag: ${EXPECTED_TAG}" | |
| echo "" | |
| echo "Option 3: Manual dispatch with the correct tag" | |
| echo " - Go to Actions > 'Create Release' > Run workflow" | |
| echo " - Enter tag_name: ${EXPECTED_TAG}" | |
| echo "=========================================" | |
| exit 1 | |
| fi | |
| echo "✅ Tag matches gradle.properties version." | |
| - name: Create Release | |
| id: create_release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ inputs.tag_name || github.ref_name }} | |
| name: ${{ inputs.tag_name || github.ref_name }} | |
| draft: false | |
| prerelease: ${{ inputs.prerelease || false }} | |
| generate_release_notes: false | |
| build_release: | |
| name: Build Release | |
| needs: create_release | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest] | |
| include: | |
| - os: ubuntu-latest | |
| release_suffix: ubuntu | |
| - os: ubuntu-24.04-arm | |
| release_suffix: ubuntu-arm | |
| - os: macos-latest | |
| release_suffix: mac | |
| - os: windows-latest | |
| release_suffix: windows | |
| # windows-arm removed - no GitHub-hosted runner available yet | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ inputs.tag_name || github.ref }} | |
| - name: Update PCGenProp.properties with release version and date | |
| run: | | |
| PROPS_FILE="code/src/resources/pcgen/system/prop/PCGenProp.properties" | |
| GRADLE_VERSION=$(grep '^version=' gradle.properties | head -1 | cut -d'=' -f2 | tr -d '[:space:]') | |
| RELEASE_DATE=$(date -u +%Y-%m-%d) | |
| echo "Setting VersionNumber=${GRADLE_VERSION} and ReleaseDate=${RELEASE_DATE} in ${PROPS_FILE}" | |
| sed -i.bak "s/^VersionNumber=.*/VersionNumber=${GRADLE_VERSION}/" "${PROPS_FILE}" | |
| sed -i.bak "s/^ReleaseDate=.*/ReleaseDate=${RELEASE_DATE}/" "${PROPS_FILE}" | |
| rm -f "${PROPS_FILE}.bak" | |
| echo "Updated ${PROPS_FILE}:" | |
| grep -E '^(VersionNumber|ReleaseDate)=' "${PROPS_FILE}" | |
| - name: Set up JDK 25 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '25' | |
| distribution: 'temurin' | |
| cache: gradle | |
| cache-dependency-path: | | |
| build.gradle | |
| code/gradle/autobuild.gradle | |
| code/gradle/distribution.gradle | |
| code/gradle/release.gradle | |
| code/gradle/reporting.gradle | |
| code/gradle/plugins.gradle | |
| # Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies. | |
| # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| with: | |
| cache-disabled: false | |
| cache-read-only: false | |
| cache-overwrite-existing: true | |
| - uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ${{ github.workspace }}/build/jre | |
| ${{ github.workspace }}/build/libs | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ matrix.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| ${{ matrix.os }}-gradle | |
| - name: Build the image | |
| if: success() | |
| run: ./gradlew clean build copyToOutput test compileSlowtest datatest pfinttest allReports buildDist prepareRelease pcgenRelease | |
| - name: Upload zip based release assets for all platforms | |
| uses: actions/upload-artifact@v4 | |
| if: matrix.os == 'macos-latest' | |
| with: | |
| name: ${{ matrix.os }}-zip | |
| path: ${{ github.workspace }}/build/release/image-*.zip | |
| - name: Upload DMG release asset for macos | |
| uses: actions/upload-artifact@v4 | |
| if: matrix.os == 'macos-latest' | |
| with: | |
| name: ${{ matrix.os }}-dmg | |
| path: ${{ github.workspace }}/build/release/*.dmg | |
| - name: Upload PKG release asset for macos | |
| uses: actions/upload-artifact@v4 | |
| if: matrix.os == 'macos-latest' | |
| with: | |
| name: ${{ matrix.os }}-pkg | |
| path: ${{ github.workspace }}/build/release/*.pkg | |
| # - name: Upload release assets for ubuntu | |
| # uses: actions/upload-artifact@v4 | |
| # if: matrix.os == 'ubuntu-latest' | |
| # with: | |
| # name: ${{ matrix.os }} | |
| # path: ${{ github.workspace }}/build/jpackage/*.deb | |
| # | |
| # - name: Upload release assets for windows | |
| # uses: actions/upload-artifact@v4 | |
| # if: matrix.os == 'windows-latest' | |
| # with: | |
| # name: ${{ matrix.os }} | |
| # path: ${{ github.workspace }}/build/jpackage/*.msi | |
| # | |
| # - name: Release - ${{ matrix.os }} | |
| # uses: softprops/action-gh-release@v2 | |
| # with: | |
| # tag_name: ${{ needs.create_release.outputs.tag-name }} | |
| # files: ${{ github.workspace }}/build/release/pcgen-*.* |