-
Notifications
You must be signed in to change notification settings - Fork 3
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
24 changed files
with
574 additions
and
124 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 |
---|---|---|
|
@@ -6,19 +6,14 @@ on: | |
tags: | ||
- '*' | ||
|
||
env: | ||
# For any reason, specifying this in the modrinth step does not work? | ||
# But it is also well documented here, so this should be ok to do | ||
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
version: ['1.19', '1.19.1', '1.19.2', '1.19.3', '1.19.4', '1.20', '1.20.1', '1.20.2'] | ||
fail-fast: true | ||
steps: | ||
- name: Check tag condition | ||
if: startsWith(github.ref, 'refs/tags/') | ||
run: echo "Ref is a tag" | ||
|
||
- name: Check out project | ||
if: success() | ||
uses: actions/checkout@v3 | ||
|
@@ -36,14 +31,38 @@ jobs: | |
if: success() | ||
uses: gradle/gradle-build-action@v2 | ||
with: | ||
gradle-version: 7.4.2 | ||
gradle-version: 8.3 | ||
|
||
- name: Build | ||
if: success() | ||
run: gradle remapJar | ||
run: gradle remapJar -Pv=${{ matrix.version }} | ||
|
||
- name: Upload artifact | ||
if: success() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: build-${{ matrix.version }} | ||
path: | | ||
**/libs/server-portals-*.jar | ||
release: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Check out metadata | ||
uses: actions/checkout@v3 | ||
with: | ||
sparse-checkout: | | ||
README.md | ||
CHANGELOG.md | ||
LICENSE | ||
- name: Download artifacts | ||
if: success() | ||
uses: actions/download-artifact@v3 | ||
|
||
- name: Release on GitHub | ||
if: success() && startsWith(github.ref, 'refs/tags/') # Failsafe check again | ||
- name: Release on github | ||
if: success() # No git tag check, since action-gh-release fails if not valid | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
|
@@ -56,6 +75,57 @@ jobs: | |
prerelease: false | ||
fail_on_unmatched_files: true | ||
|
||
- name: Upload to modrinth | ||
publish: | ||
runs-on: ubuntu-latest | ||
needs: release | ||
strategy: | ||
matrix: | ||
version: ['1.19', '1.19.1', '1.19.2', '1.19.3', '1.19.4', '1.20', '1.20.1', '1.20.2'] | ||
fail-fast: true | ||
steps: | ||
- name: Check out metadata | ||
uses: actions/checkout@v3 | ||
with: | ||
sparse-checkout: | | ||
CHANGELOG.md | ||
- name: Download artifact | ||
if: success() | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: build-${{ matrix.version }} | ||
|
||
- name: Publish on modrinth | ||
if: success() && startsWith(github.ref, 'refs/tags/') # Failsafe check | ||
# See https://github.com/Kir-Antipov/mc-publish | ||
uses: Kir-Antipov/[email protected] | ||
with: | ||
modrinth-id: server-portals | ||
modrinth-token: ${{ secrets.MODRINTH_TOKEN }} | ||
modrinth-featured: false | ||
files: | | ||
**/libs/server-portals-*.jar | ||
name: Server Portals ${{ github.ref_name }} | ||
version: ${{ github.ref_name }}+${{ matrix.version }} | ||
version-type: "${{ contains(github.ref_name, 'SNAPSHOT') && 'alpha' || 'release' }}" | ||
changelog-file: CHANGELOG.md | ||
#loaders: fabric | ||
game-versions: "=${{ matrix.version }}" | ||
#dependencies: | ||
|
||
publish_readme: | ||
runs-on: ubuntu-latest | ||
needs: publish | ||
steps: | ||
- name: Check out metadata | ||
uses: actions/checkout@v3 | ||
with: | ||
sparse-checkout: | | ||
README.md | ||
- name: Update readme | ||
if: success() | ||
run: gradle modrinth | ||
run: | | ||
readme="$(sed 's/\\/\\\\/g; s/"/\\"/g; s/$/\\n/' README.md)" | ||
json="{ \"body\": \"$readme\" }" | ||
echo "$json" | curl -XPATCH -H "Authorization: ${{ secrets.MODRINTH_TOKEN }}" -H "Content-type: application/json" -d @- 'https://api.modrinth.com/v2/project/server-portals' |
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,23 @@ | ||
# See https://github.com/marketplace/actions/remove-artifacts | ||
name: Remove old artifacts | ||
|
||
on: | ||
schedule: | ||
# Every day at 1am | ||
- cron: '0 1 * * *' | ||
|
||
jobs: | ||
remove-old-artifacts: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
|
||
steps: | ||
- name: Remove old artifacts | ||
uses: c-hive/gha-remove-artifacts@v1 | ||
with: | ||
# '<number> <unit>', e.g. 5 days, 2 years, 90 seconds, parsed by Moment.js | ||
age: '2 days' | ||
|
||
# Optional inputs | ||
# skip-tags: true | ||
# skip-recent: 5 |
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 +1 @@ | ||
Initial project creation | ||
Support for MC 1.19 - 1.20.2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
allprojects { | ||
// This can get extracted into a root build.gradle if needed | ||
ext { | ||
getLatestTag = { | ||
new ByteArrayOutputStream().withStream { os -> | ||
exec { | ||
executable = "git" | ||
args = ["describe", "--tags", "--abbrev=0"] | ||
standardOutput = os | ||
} | ||
return os.toString().trim() | ||
} | ||
} | ||
|
||
getCurrentCommitCount = { | ||
new ByteArrayOutputStream().withStream { os -> | ||
exec { | ||
executable = "git" | ||
args = ["rev-list", "--all", "--count"] | ||
standardOutput = os | ||
} | ||
return os.toString().trim() | ||
} | ||
} | ||
} | ||
|
||
try { | ||
project.version = "${project.getLatestTag()}.${project.getCurrentCommitCount()}" | ||
} catch (Exception ignored) { | ||
println('Either git is not set up properly, or there is no tag yet in the repository. Falling back to version \'0\'') | ||
project.version = '0' | ||
} | ||
project.group = 'michiruf' | ||
} |
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
Oops, something went wrong.