Merge pull request #4 from U5B/dev #9
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
name: publish main | |
on: | |
push: | |
branches: | |
- 'main' | |
jobs: | |
publish: | |
runs-on: ubuntu-22.04 | |
env: | |
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} | |
PROD: TRUE | |
steps: | |
- name: checkout repository | |
uses: actions/checkout@v3 | |
- name: validate gradle wrapper | |
uses: gradle/wrapper-validation-action@v1 | |
- name: setup jdk 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: 'microsoft' | |
- name: make gradle wrapper executable | |
run: chmod +x ./gradlew | |
# from https://github.com/orgs/community/discussions/35120#discussioncomment-3805387 | |
- name: get changelog | |
id: changelog | |
uses: actions/github-script@v6.3.1 | |
env: | |
COMMITS: ${{ toJSON(github.event.commits) }} | |
with: | |
result-encoding: string | |
script: | | |
const commits = JSON.parse(process.env.COMMITS); | |
var lines = ""; | |
for (const commit of commits) { | |
lines += "* " + commit.message + " (" + commit.id.substring(0,8) + ") @" + commit.author.username + "\n" | |
} | |
return lines | |
- name: publish to modrinth | |
env: | |
CHANGELOG: ${{ steps.changelog.outputs.result }} | |
run: ./gradlew modrinth | |
# from https://github.com/JsMacros/JsMacros/blob/d0991a04159eb54b32b534e4bcac96b5ce613ccb/.github/workflows/betabuild.yml | |
- name: get current mod version | |
uses: actions/github-script@v2 | |
id: mod_version | |
with: | |
result-encoding: string | |
script: | | |
const fs = require("fs"); | |
let file = fs.readFileSync("./gradle.properties"); | |
const mod_version = file.toString().split("\n").filter(e => e.trim().startsWith("mod_version"))[0].split("=")[1].trim(); | |
return mod_version; | |
- name: create tag | |
uses: rickstaa/action-create-tag@v1 | |
id: "tag_create" | |
with: | |
tag: ${{ steps.mod_version.outputs.result }} | |
tag_exists_error: false | |
message: "" |