Merge pull request #201 from uskyblock/release/3.6.1 #427
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: Gradle build | |
| on: | |
| push: | |
| branches: [ master ] | |
| tags: [ 'v*' ] | |
| pull_request: | |
| branches: [ master ] | |
| permissions: | |
| contents: write | |
| jobs: | |
| build_and_test: | |
| if: github.repository_owner == 'uskyblock' | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| - name: JDK 21 | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Install gettext | |
| run: sudo apt-get install -y gettext | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v6.3.0 | |
| - name: Verify translation templates are up to date (PR + main) | |
| if: ${{ github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/master') }} | |
| run: | | |
| set -euo pipefail | |
| ./gradlew :uSkyBlock-Core:extractTranslation --no-daemon --no-configuration-cache | |
| set -- $(find uSkyBlock-Core/src/main/i18n -type f -name '*.pot' | sort) | |
| if [ "$#" -eq 0 ]; then | |
| echo "No .pot files found under uSkyBlock-Core/src/main/i18n" >&2 | |
| exit 1 | |
| fi | |
| echo "Verifying drift for $#: .pot file(s)" | |
| for pot_file in "$@"; do | |
| echo " - $pot_file" | |
| done | |
| git diff --exit-code -- "$@" | |
| - name: Verify tag matches Gradle version | |
| if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} | |
| run: ./gradlew verifyReleaseTag -PreleaseTag="${GITHUB_REF_NAME}" --no-daemon --no-configuration-cache | |
| - name: Build with Gradle | |
| run: ./gradlew build translation publishAllPublicationsToStagingRepository --no-daemon --no-configuration-cache | |
| # Install our SSH key: | |
| - name: Install SSH key | |
| uses: shimataro/ssh-key-action@v2 | |
| if: ${{ github.event_name == 'push' }} | |
| with: | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| known_hosts: ${{ secrets.SSH_KNOWN_HOST }} | |
| # Mark our scripts runnable: | |
| - name: Mark deploy scripts runnable | |
| if: ${{ github.event_name == 'push' }} | |
| run: | | |
| chmod +x "${GITHUB_WORKSPACE}/.github/deploy-staging.sh" | |
| chmod +x "${GITHUB_WORKSPACE}/.github/deploy-release.sh" | |
| # Deploy from master branch (staging release): | |
| - name: Run deploy script for staging release | |
| if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} | |
| run: "${GITHUB_WORKSPACE}/.github/deploy-staging.sh" | |
| # Deploy from tag create (plugin release): | |
| - name: Run deploy script for plugin release | |
| if: ${{ github.event_name == 'push' && startsWith( github.ref, 'refs/tags/') }} | |
| run: "${GITHUB_WORKSPACE}/.github/deploy-release.sh" | |
| - name: Locate release JAR | |
| if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} | |
| id: jar | |
| run: | | |
| set -euo pipefail | |
| # Match the shaded plugin jar exactly (uSkyBlock-<version>.jar). A bare | |
| # 'uSkyBlock-*.jar' glob also matches the javadoc jar | |
| # (uSkyBlock-Plugin-<version>-javadoc.jar), and find/head could then attach | |
| # the wrong artifact. verifyReleaseTag guarantees the tag equals the version. | |
| jar_path="$(find uSkyBlock-Plugin/build/libs -maxdepth 1 -type f -name "uSkyBlock-${GITHUB_REF_NAME#v}.jar" | head -n 1)" | |
| if [ -z "${jar_path}" ]; then | |
| echo "Release JAR not found." >&2 | |
| exit 1 | |
| fi | |
| echo "jar_path=${jar_path}" >> "${GITHUB_OUTPUT}" | |
| echo "jar_name=$(basename "${jar_path}")" >> "${GITHUB_OUTPUT}" | |
| - name: Create or update draft release | |
| if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| set -euo pipefail | |
| tag="${GITHUB_REF_NAME}" | |
| title="${tag#v}" | |
| asset="${{ steps.jar.outputs.jar_path }}#${{ steps.jar.outputs.jar_name }}" | |
| if gh release view "${tag}" >/dev/null 2>&1; then | |
| gh release upload "${tag}" "${asset}" --clobber | |
| else | |
| gh release create "${tag}" "${asset}" \ | |
| --draft \ | |
| --verify-tag \ | |
| --generate-notes \ | |
| --title "${title}" | |
| fi | |
| - name: Summarize release URL | |
| if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| set -euo pipefail | |
| release_url="$(gh release view "${GITHUB_REF_NAME}" --json url --jq '.url')" | |
| echo "Draft release: ${release_url}" >> "${GITHUB_STEP_SUMMARY}" |