-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
153 lines (139 loc) · 5.32 KB
/
Copy pathaction.yml
File metadata and controls
153 lines (139 loc) · 5.32 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: 'Publish MineInAbyss packages'
description: 'Publishes to our maven repo, documentation, and release jars'
inputs:
pages-path:
description: 'The path to publish to GitHub Pages'
required: false
default: ''
run-gradle-build:
description: 'Whether to run a default gradle build'
required: false
default: 'true'
dokka:
description: 'The type of dokka build to run'
required: false
default: ''
release-files:
description: 'The files to attach to the release'
required: false
default: ''
publish-github-release:
description: 'Whether to publish a GitHub release'
required: false
default: 'true'
maven-username:
description: 'The username of the repository to publish to'
required: false
default: ''
maven-password:
description: 'The password of the repository to publish to'
required: false
default: ''
pre-build:
description: 'Shell commands to run before building with gradle'
required: false
default: ''
build-tasks:
description: 'Tasks to run for the gradle build, can have multiple space separated tasks'
required: false
default: 'build publish'
changelog-prefix-file:
description: 'A file path to prefix the changelog with'
required: false
default: ''
skip-java-setup:
description: "Don't run setup JDK and gradle tasks (useful if another action using this one needs them setup manually)"
required: false
default: false
snapshot-branch:
description: 'When the workflow runs on this branch, publish to snapshots instead of releases'
required: false
default: 'develop'
runs:
using: "composite"
steps:
- shell: bash
run: echo "IS_SNAPSHOT=${{github.ref == format('refs/heads/{0}', inputs.snapshot-branch)}}" >> $GITHUB_ENV
- name: ☕️ Set up JDK
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 21
if: ${{ inputs.skip-java-setup != 'true' }}
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
if: ${{ inputs.skip-java-setup != 'true' }}
- name: Grant execute permission for gradlew
shell: bash
run: chmod +x gradlew
- name: 🐘️ Get MAJOR.MINOR version from gradle
shell: bash
id: extract_version
run: |
echo "VERSION"=$(./gradlew properties --console=plain -q | grep "^version:" | awk '{printf $2}') >> $GITHUB_ENV
if: ${{ inputs.publish-github-release == 'true' }}
- name: Get next semver version
shell: bash
run: echo "BUMPED_VERSION"=$(${{ github.action_path }}/nextVersion.main.kts $VERSION master) >> $GITHUB_ENV
- name: 🐘️ Run pre-build tasks
shell: bash
run: ${{ inputs.pre-build }}
if: ${{ inputs.pre-build != '' }}
- name: 🐘️ Run gradle build and publish
shell: bash
run: >
./gradlew ${{ inputs.build-tasks }}
-PmineinabyssMavenUsername=${{ inputs.maven-username }}
-PmineinabyssMavenPassword=${{ inputs.maven-password }}
-Pplugin_path=${{ github.workspace }}/publish
-Pversion=$BUMPED_VERSION
-Ppaperweight.experimental.sharedCaches=true
if: ${{ inputs.run-gradle-build == 'true' }}
- name: 📜️ Build with dokka
shell: bash
run: ./gradlew ${{ inputs.dokka }}
if: ${{ inputs.run-gradle-build == 'true' && inputs.dokka != '' && env.IS_SNAPSHOT == false }}
- name: Copy cliff config to workspace for docker
shell: bash
run: |
mkdir -p ${{ github.workspace }}/mineinabyss-cliff
cp ${{ github.action_path }}/mineinabyss-cliff.toml ${{ github.workspace }}/mineinabyss-cliff/cliff.toml
if: ${{ inputs.publish-github-release == 'true' }}
- name: Get changelog from CHANGELOG.md if present
shell: bash
id: changelog
continue-on-error: true
run: |
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
${{ github.action_path }}/changelog.main.kts '${{ env.BUMPED_VERSION }}' >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: 📃️ Generate a changelog
uses: orhun/git-cliff-action@v4
id: git-cliff
with:
config: "./mineinabyss-cliff/cliff.toml"
args: --unreleased ${{ !env.IS_SNAPSHOT && '--ignore-tags=".*-(alpha|dev|pre|beta).*"' || '' }} --github-repo ${{ github.repository }}
if: ${{ inputs.publish-github-release == 'true' && steps.changelog.outcome == 'failure' }}
- name: Read changelog prefix file
id: changelog-prefix
uses: juliangruber/read-file-action@v1
with:
path: ${{ inputs.changelog-prefix-file }}
if: ${{ inputs.changelog-prefix-file != '' }}
- name: 📦️ Create GitHub Release
uses: softprops/action-gh-release@v2
with:
token: ${{ github.token }}
target_commitish: ${{ github.sha }}
body: >
${{ steps.changelog-prefix.outputs.content || '' }}
${{ steps.changelog.outputs.CHANGELOG || steps.git-cliff.outputs.content }}
prerelease: ${{ env.IS_SNAPSHOT }}
tag_name: v${{ env.BUMPED_VERSION }}
files: ${{ inputs.release-files }}
if: ${{ inputs.publish-github-release == 'true' }}
- name: Upload github pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ${{ inputs.pages-path }}
if: ${{ inputs.pages-path != '' && env.IS_SNAPSHOT == false }}