generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Setup version naming scheme & auto release CI (#18)
* build: Change version number to git-based system Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * ci: Setup basic beta build and publish action Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * ci: Enable ` --stacktrace` for gradle build Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * ci: Fix mod info getter Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * ci: Remove pull_request dispatch for pre-release action Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * ci: Setup `REDEN_BUILD_TYPE` ENV Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * ci: Add build action for PRs Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * ci: Allow multiple artifacts for dev ci Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * ci: Enable Gradle Cache Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * build: Add a version suffix when building with GitHub Action Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * ci: Fix release condition * ci: Add ci-build version suffix only when beta * ci: Add more publish requirement Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * ci: Add ability to manually trigger beta release * ci: Add stable release CI Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * ci: Fix Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> * ci: Fix auto stable release tag * ci: Add publish to Modrinth & CurseForge Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top> --------- Signed-off-by: Qian Qian "Cubik" <cubik65536@cubik65536.top>
- Loading branch information
1 parent
0fe3d76
commit e855ae2
Showing
6 changed files
with
325 additions
and
35 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 |
---|---|---|
@@ -0,0 +1,98 @@ | ||
name: Build Stable Release version and Publish | ||
|
||
on: | ||
release: | ||
# It is recommended to set the release tag as "v.<major>.<minor>-patch.<patch>" (e.g. "v.1.0-patch.1") when creating a release. | ||
types: [released] | ||
|
||
jobs: | ||
build-and-publish-pre-release: | ||
strategy: | ||
matrix: | ||
# Use thses Java versions: | ||
java: [17] # Only use the latest Java LTS | ||
# Use these operating systems: | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK ${{ matrix.java }} | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: temurin | ||
java-version: ${{ matrix.java }} | ||
- name: Show Java version | ||
run: java -version | ||
- name: Validate Gradle Wrapper | ||
uses: gradle/wrapper-validation-action@v1 | ||
- name: Setup Gradle | ||
uses: gradle/gradle-build-action@v2 | ||
- name: Show Gradle version | ||
run: gradle --version | ||
|
||
- name: Build with Gradle | ||
env: | ||
REDEN_BUILD_TYPE: "RELEASE" | ||
run: gradle build --stacktrace | ||
|
||
- name: Get Mod Info | ||
id: get_mod_info | ||
uses: christian-draeger/read-properties@1.1.1 | ||
with: | ||
path: gradle.properties | ||
properties: 'mod_name mod_version' | ||
- name: Get commit SHA | ||
id: get_commit_sha | ||
run: | | ||
short_sha=$(echo ${GITHUB_SHA} | cut -c1-7) | ||
echo "short_sha=$short_sha" >> $GITHUB_OUTPUT | ||
- name: Get commit count | ||
id: get_commit_count | ||
run: | | ||
commit_count=$(git log | grep -e '^commit [a-zA-Z0-9]*' | wc -l) | ||
echo "commit_count=$commit_count" >> $GITHUB_OUTPUT | ||
- name: Upload assets to GitHub Action | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: "${{ steps.get_mod_info.outputs.mod_name }} ${{ steps.get_mod_info.outputs.mod_version }}.${{ steps.get_commit_count.outputs.commit_count }}+${{ steps.get_commit_sha.outputs.short_sha }}" | ||
path: build/libs/*.jar | ||
|
||
- name: Publish to GitHub Releases | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
allowUpdates: true | ||
artifacts: build/libs/*.jar | ||
body: "[RELEASE-CI#${{ github.run_number }}] ${{ steps.get_mod_info.outputs.mod_name }} Mod Stable Release ${{ steps.get_mod_info.outputs.mod_version }}.${{ steps.get_commit_count.outputs.commit_count }}+${{ steps.get_commit_sha.outputs.short_sha }}" | ||
generateReleaseNotes: true | ||
makeLatest: true | ||
tag: ${{ github.event.ref }} | ||
|
||
- name: Publish to Modrinth & CurseForge | ||
uses: Kir-Antipov/mc-publish@v3.3 | ||
with: | ||
# Publish to Modrinth | ||
modrinth-id: xRu8OXEJ | ||
modrinth-token: ${{ secrets.MODRINTH_TOKEN }} | ||
# Publish to CurseForge | ||
curseforge-id: 903236 | ||
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} | ||
# Universal Configurations | ||
files: | | ||
build/libs/!(*-@(dev|beta|sources|javadoc)).jar | ||
build/libs/*-@(dev|beta|sources|javadocs).jar | ||
name: "${{ steps.get_mod_info.outputs.mod_name }} ${{ steps.get_mod_info.outputs.mod_version }}.${{ steps.get_commit_count.outputs.commit_count }}+${{ steps.get_commit_sha.outputs.short_sha }}" | ||
version: "${{ steps.get_mod_info.outputs.mod_version }}.${{ steps.get_commit_count.outputs.commit_count }}+${{ steps.get_commit_sha.outputs.short_sha }}" | ||
version-type: release | ||
|
||
loaders: fabric | ||
game-versions: 1.20.1 | ||
game-version-filter: any | ||
java: | | ||
17 | ||
18 | ||
19 | ||
20 | ||
retry-attempts: 2 | ||
retry-delay: 10000 |
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 |
---|---|---|
@@ -0,0 +1,119 @@ | ||
name: Build Pre-Release version and Publish | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release-beta: | ||
description: 'Publish a beta release?' | ||
required: true | ||
type: boolean | ||
push: | ||
branches: | ||
- '**' # Pushes to any branch | ||
|
||
jobs: | ||
build-and-publish-pre-release: | ||
strategy: | ||
matrix: | ||
# Use thses Java versions: | ||
java: [17, 20] # Current Java LTS and current latest Java version | ||
# Use these operating systems: | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Store all lowercase commit message | ||
run: | | ||
echo "COMMIT_MESSAGE=$(echo ${github.event.head_commit.message} | tr '[:upper:]' '[:lower:]')" >> ${GITHUB_ENV} | ||
- name: Detect if a beta release should be published | ||
if: ${{ contains(env.COMMIT_MESSAGE, '[publish beta]') || inputs.release-beta }} | ||
run: | | ||
echo "PUBLISH_BETA=true" >> ${GITHUB_ENV} | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK ${{ matrix.java }} | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: temurin | ||
java-version: ${{ matrix.java }} | ||
- name: Show Java version | ||
run: java -version | ||
- name: Validate Gradle Wrapper | ||
uses: gradle/wrapper-validation-action@v1 | ||
- name: Setup Gradle | ||
uses: gradle/gradle-build-action@v2 | ||
- name: Show Gradle version | ||
run: gradle --version | ||
|
||
|
||
- name: Build with Gradle (DEV) | ||
if : ${{ env.PUBLISH_BETA != 'true' }} | ||
run: gradle build --stacktrace | ||
- name: Build with Gradle (BETA) | ||
if : ${{ env.PUBLISH_BETA == 'true' }} | ||
env: | ||
REDEN_BUILD_TYPE: "BETA" | ||
run: gradle build --stacktrace | ||
|
||
- name: Get Mod Info | ||
id: get_mod_info | ||
uses: christian-draeger/read-properties@1.1.1 | ||
with: | ||
path: gradle.properties | ||
properties: 'mod_name mod_version' | ||
- name: Get commit SHA | ||
id: get_commit_sha | ||
run: | | ||
short_sha=$(echo ${GITHUB_SHA} | cut -c1-7) | ||
echo "short_sha=$short_sha" >> $GITHUB_OUTPUT | ||
- name: Get commit count | ||
id: get_commit_count | ||
run: | | ||
commit_count=$(git log | grep -e '^commit [a-zA-Z0-9]*' | wc -l) | ||
echo "commit_count=$commit_count" >> $GITHUB_OUTPUT | ||
- name: Upload assets to GitHub Action | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: "[DEV-CI#${{ github.run_number }}] ${{ steps.get_mod_info.outputs.mod_name }} ${{ steps.get_mod_info.outputs.mod_version }}.${{ steps.get_commit_count.outputs.commit_count }}+${{ steps.get_commit_sha.outputs.short_sha }} - Java ${{ matrix.java }}" | ||
path: build/libs/*.jar | ||
|
||
- name: Publish to GitHub Pre-Releases | ||
if: ${{ env.PUBLISH_BETA == 'true' && matrix.java == 17 }} # Only publish the version built with Java LTS | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
allowUpdates: true | ||
artifacts: build/libs/*.jar | ||
generateReleaseNotes: true | ||
name: "[CI#${{ github.run_number }}] ${{ steps.get_mod_info.outputs.mod_name }} Mod Pre-Release ${{ steps.get_mod_info.outputs.mod_version }}.${{ steps.get_commit_count.outputs.commit_count }}+${{ steps.get_commit_sha.outputs.short_sha }}" | ||
prerelease: true | ||
tag: "beta/${{ steps.get_commit_sha.outputs.short_sha }}" | ||
|
||
- name: Publish to Modrinth & CurseForge | ||
if: ${{ env.PUBLISH_BETA == 'true' && matrix.java == 17 }} # Only publish the version built with Java LTS | ||
uses: Kir-Antipov/mc-publish@v3.3 | ||
with: | ||
# Publish to Modrinth | ||
modrinth-id: xRu8OXEJ | ||
modrinth-token: ${{ secrets.MODRINTH_TOKEN }} | ||
# Publish to CurseForge | ||
curseforge-id: 903236 | ||
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} | ||
# Universal Configurations | ||
files: | | ||
build/libs/!(*-@(dev|sources|javadoc)).jar | ||
build/libs/*-@(dev|sources|javadocs).jar | ||
name: "${{ steps.get_mod_info.outputs.mod_name }} Pre-Release ${{ steps.get_mod_info.outputs.mod_version }}.${{ steps.get_commit_count.outputs.commit_count }}+${{ steps.get_commit_sha.outputs.short_sha }}" | ||
version: "beta/${{ steps.get_mod_info.outputs.mod_version }}.${{ steps.get_commit_count.outputs.commit_count }}+${{ steps.get_commit_sha.outputs.short_sha }}" | ||
version-type: beta | ||
|
||
loaders: fabric | ||
game-versions: 1.20.1 | ||
game-version-filter: any | ||
java: | | ||
17 | ||
18 | ||
19 | ||
20 | ||
retry-attempts: 2 | ||
retry-delay: 10000 |
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Build from Pull Request | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
build-pr: | ||
strategy: | ||
matrix: | ||
# Use thses Java versions: | ||
java: [17, 20] # Current Java LTS and current latest Java version | ||
# Use these operating systems: | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK ${{ matrix.java }} | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: temurin | ||
java-version: ${{ matrix.java }} | ||
- name: Show Java version | ||
run: java -version | ||
- name: Validate Gradle Wrapper | ||
uses: gradle/wrapper-validation-action@v1 | ||
- name: Setup Gradle | ||
uses: gradle/gradle-build-action@v2 | ||
- name: Show Gradle version | ||
run: gradle --version | ||
|
||
|
||
- name: Build with Gradle | ||
run: gradle build --stacktrace | ||
|
||
- name: Get Mod Info | ||
id: get_mod_info | ||
uses: christian-draeger/read-properties@1.1.1 | ||
with: | ||
path: gradle.properties | ||
properties: 'mod_name mod_version' | ||
- name: Get commit SHA | ||
id: get_commit_sha | ||
run: | | ||
short_sha=$(echo ${GITHUB_SHA} | cut -c1-7) | ||
echo "short_sha=$short_sha" >> $GITHUB_OUTPUT | ||
- name: Get commit count | ||
id: get_commit_count | ||
run: | | ||
commit_count=$(git log | grep -e '^commit [a-zA-Z0-9]*' | wc -l) | ||
echo "commit_count=$commit_count" >> $GITHUB_OUTPUT | ||
- name: Upload assets to GitHub Action | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: "[PR-CI#${{ github.run_number }}] ${{ steps.get_mod_info.outputs.mod_name }} ${{ steps.get_mod_info.outputs.mod_version }}.${{ steps.get_commit_count.outputs.commit_count }}+${{ steps.get_commit_sha.outputs.short_sha }} - Java ${{ matrix.java }}" | ||
path: build/libs/*.jar |
This file was deleted.
Oops, something went wrong.
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
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