|
| 1 | +# Publishes built jars to distribution platforms |
| 2 | +name: Publish |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - 'v[0-9]+.[0-9]+.[0-9]+' # any semver tag, e.g. v1.2.3 |
| 8 | + |
| 9 | +env: |
| 10 | + # link to the changelog with a format code for the version |
| 11 | + CHANGELOG_LOCATION: "Changelog is available [here](https://github.com/${{github.repository}}/releases/tag/${{github.ref_name}})" |
| 12 | + # type of release |
| 13 | + RELEASE_TYPE: "beta" |
| 14 | + |
| 15 | +jobs: |
| 16 | + Publish: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + permissions: |
| 20 | + contents: write # needed to create GitHub releases |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout Repository |
| 24 | + uses: actions/checkout@v3 |
| 25 | + |
| 26 | + - name: Check for Duplicate Tags |
| 27 | + run: | |
| 28 | + if git rev-parse -q --verify "refs/tags/${{ github.ref }}" >/dev/null; then |
| 29 | + echo "Tag already exists. A version bump is required." |
| 30 | + exit 1 |
| 31 | + fi |
| 32 | +
|
| 33 | + - name: Setup Java |
| 34 | + uses: actions/setup-java@v3 |
| 35 | + with: |
| 36 | + distribution: zulu |
| 37 | + java-version: 17 |
| 38 | + |
| 39 | + - name: Build Project |
| 40 | + uses: gradle/gradle-build-action@v2 |
| 41 | + with: |
| 42 | + arguments: 'build --build-cache --daemon' # use the daemon here so the rest of the process is faster |
| 43 | + generate-job-summary: false |
| 44 | + gradle-home-cache-includes: | |
| 45 | + caches |
| 46 | + jdks |
| 47 | + notifications |
| 48 | + wrapper |
| 49 | +
|
| 50 | + - name: Publish to GitHub |
| 51 | + uses: softprops/action-gh-release@v1 |
| 52 | + with: |
| 53 | + files: "build/libs/*.jar" |
| 54 | + generate_release_notes: true |
| 55 | + fail_on_unmatched_files: true |
| 56 | + |
| 57 | + - name: Publish to Curseforge |
| 58 | + uses: gradle/gradle-build-action@v2 |
| 59 | + env: |
| 60 | + CURSEFORGE_API_KEY: "${{secrets.CURSEFORGE_API_KEY}}" |
| 61 | + CURSEFORGE_PROJECT_ID: "${{secrets.CURSEFORGE_PROJECT_ID}}" |
| 62 | + CHANGELOG_LOCATION: "${{env.CHANGELOG_LOCATION}}" |
| 63 | + RELEASE_TYPE: "${{env.RELEASE_TYPE}}" |
| 64 | + with: |
| 65 | + arguments: 'curseforge --daemon' |
| 66 | + generate-job-summary: false |
| 67 | + gradle-home-cache-includes: | |
| 68 | + caches |
| 69 | + jdks |
| 70 | + notifications |
| 71 | + wrapper |
0 commit comments