-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (77 loc) · 3.09 KB
/
Copy pathrelease.yml
File metadata and controls
89 lines (77 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Release
on:
push:
branches: [main]
workflow_dispatch:
inputs:
tag:
description: "Existing release tag to (re)publish, e.g. v0.1.0"
required: true
type: string
permissions:
contents: write
pull-requests: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
release-please:
name: Maintain the release PR
# Manual runs skip straight to publishing an already-tagged version.
if: github.event_name == 'push'
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: googleapis/release-please-action@v5
id: release
publish:
name: Publish to GitHub Packages and Modrinth
needs: [release-please]
# `!cancelled()` keeps this job reachable when release-please is skipped
# (workflow_dispatch) instead of inheriting the skip.
if: >-
!cancelled()
&& (needs.release-please.outputs.release_created == 'true'
|| github.event_name == 'workflow_dispatch')
runs-on: ubuntu-latest
permissions:
# `write` is needed to attach the JAR to the GitHub release.
contents: write
packages: write
env:
TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || needs.release-please.outputs.tag_name }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || needs.release-please.outputs.tag_name }}
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "21"
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v6
# SQLite-only here; the MySQL matrix already ran on the release PR.
- name: Build
run: ./gradlew build --no-daemon --stacktrace
- name: Extract the release notes for Modrinth
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p build
gh release view "$TAG" --json body -q .body > build/modrinth-changelog.md
- name: Publish to GitHub Packages
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew publish --no-daemon --stacktrace
- name: Publish to Modrinth
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
run: ./gradlew modrinth modrinthSyncBody --no-daemon --stacktrace
- name: Attach the shaded JAR to the GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload "$TAG" build/libs/ModernVillagerShop-*.jar --clobber