-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
81 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,89 @@ | ||
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle | ||
|
||
# copied from https://github.com/GTNewHorizons/GTNH-Actions-Workflows/blob/master/.github/workflows/release-tags.yml | ||
|
||
name: Release tagged build | ||
|
||
on: | ||
push: | ||
tags: [ '*' ] | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
release-tags: | ||
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master | ||
secrets: inherit | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
VERSION: ${{ github.ref_name }} | ||
RELEASE_VERSION: ${{ github.ref_name }} | ||
SNAPSHOT: ${{ endsWith(github.ref_name, '-snapshot') || contains(github.event.head_commit.message, '[snapshot]') }} | ||
MAVEN_PUBLISHING_URL: ${{ vars.MAVEN_PUBLISHING_URL || 'https://nexus.gtnewhorizons.com/repository/releases/' }} | ||
steps: | ||
- name: Checkout mod repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 32 | ||
|
||
- name: Validate gradle wrapper checksum | ||
uses: gradle/wrapper-validation-action@v2 | ||
|
||
- name: Set up JDK versions | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: | | ||
8 | ||
21 | ||
17 | ||
distribution: 'zulu' | ||
cache: gradle | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Setup the workspace | ||
run: ./gradlew --build-cache --info --stacktrace -PmavenPublishUrl='${{ env.MAVEN_PUBLISHING_URL }}' ${{ inputs.workspace }} | ||
|
||
- name: Build the mod | ||
run: ./gradlew --build-cache --info --stacktrace -PmavenPublishUrl='${{ env.MAVEN_PUBLISHING_URL }}' assemble | ||
|
||
# Continue on error in the following steps to make sure releases still get made even if one of the methods fails | ||
|
||
- name: Delete old release if it already exists | ||
run: gh release delete --yes "${RELEASE_VERSION}" | ||
continue-on-error: true | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Release under current tag | ||
run: | | ||
PRERELEASE="" | ||
if [[ "$SNAPSHOT" == "true" ]]; then | ||
PRERELEASE="--prerelease" | ||
fi | ||
export "CHANGELOG_FILE=$(mktemp --suffix=.md)" | ||
echo "CHANGELOG_FILE=${CHANGELOG_FILE}" >> $GITHUB_ENV | ||
gh api --method POST -H "Accept: application/vnd.github+json" \ | ||
"/repos/${GITHUB_REPOSITORY}/releases/generate-notes" \ | ||
-f tag_name="${RELEASE_VERSION}" \ | ||
--jq ".body" > "${CHANGELOG_FILE}" | ||
cat "${CHANGELOG_FILE}" | ||
gh release create "${RELEASE_VERSION}" -F "${CHANGELOG_FILE}" $PRERELEASE ./build/libs/*.jar | ||
shell: bash | ||
continue-on-error: true | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Publish to Maven | ||
run: ./gradlew --build-cache --info --stacktrace -PmavenPublishUrl='${{ env.MAVEN_PUBLISHING_URL }}' assemble publish -x test | ||
continue-on-error: true | ||
env: | ||
MAVEN_USER: ${{ secrets.MAVEN_USER }} | ||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} | ||
if: ${{ env.MAVEN_USER != '' }} | ||
|
||
- name: Publish to Modrinth and CurseForge | ||
run: ./gradlew --build-cache --info --stacktrace -PmavenPublishUrl='${{ env.MAVEN_PUBLISHING_URL }}' assemble publish -x test | ||
continue-on-error: true | ||
env: | ||
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} | ||
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} | ||
if: ${{ env.SNAPSHOT != 'true' }} |