Repository navigation
99 lines (85 loc) · 3.37 KB
/
Copy pathdev-build.yml
File metadata and controls
99 lines (85 loc) · 3.37 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
name: Dev build
# Every push to develop makes a dev build: version <next>-dev.<run> (0.2.1-dev.57, from the
# -SNAPSHOT version in gradle.properties), built and tested, then
# - the rolling GitHub pre-release "dev" (tag moved to the commit, jar replaced), and
# - the Hangar Snapshot channel (a hyphenated version goes there).
# The "dev" tag never matches the release tag pattern, so release.yml and maven.yml do not run.
#
# A newer push cancels a build still building or testing (only the newest commit is worth
# publishing), but never a publish under way: that one finishes, and the newer publish waits.
#
# "[skip dev]" in the last commit message of a push skips the dev build (the Build workflow still
# runs); a skipped push does not cancel a build under way. "[skip ci]" skips every workflow.
on:
push:
branches: [develop]
paths-ignore:
- "docs/**"
- "**.md"
workflow_dispatch:
permissions:
contents: read
jobs:
build:
if: github.repository == '1robie/MachineEngine' && !contains(github.event.head_commit.message, '[skip dev]')
runs-on: ubuntu-latest
concurrency:
group: dev-build-build
cancel-in-progress: true
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Version
id: version
run: |
base=$(grep -oP '^version=\K.+' gradle.properties)
echo "version=${base%-SNAPSHOT}-dev.${{ github.run_number }}" >> "$GITHUB_OUTPUT"
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: |
21
25
- uses: gradle/actions/setup-gradle@v4
- name: Build and test
run: ./gradlew build -Pversion="${{ steps.version.outputs.version }}" --console=plain
- name: Check API binary compatibility
run: ./gradlew :api:japicmp -Pversion="${{ steps.version.outputs.version }}" --console=plain
publish:
needs: build
runs-on: ubuntu-latest
concurrency:
group: dev-build-publish
cancel-in-progress: false
permissions:
contents: write
env:
VERSION: ${{ needs.build.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: |
21
25
- uses: gradle/actions/setup-gradle@v4
# Tested in the build job; this only assembles the same commit's jar again.
- name: Plugin jar
run: ./gradlew :plugin:shadowJar -Pversion="$VERSION" --console=plain
- name: GitHub pre-release "dev"
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release delete dev --cleanup-tag --yes || true
gh release create dev "plugin/build/libs/MachineEngine-$VERSION.jar" \
--target "$GITHUB_SHA" --prerelease --latest=false \
--title "MachineEngine dev build ($VERSION)" \
--notes "Unstable build of \`develop\` at $GITHUB_SHA, replaced on every push. Releases: https://github.com/1robie/MachineEngine/releases"
- name: Hangar Snapshot channel
env:
HANGAR_API_TOKEN: ${{ secrets.HANGAR_API_TOKEN }}
run: |
./gradlew :plugin:publishPluginPublicationToHangar -Pversion="$VERSION" \
-Phangar_changelog="https://github.com/1robie/MachineEngine/commit/$GITHUB_SHA" --console=plain