Skip to content

Commit d301e15

Browse files
committed
Add CD and improve Actions caching
1 parent 9434759 commit d301e15

File tree

5 files changed

+41
-17
lines changed

5 files changed

+41
-17
lines changed

.github/workflows/continuous_integration.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: CI
22

33
on:
44
push:
5+
branches:
6+
- 'master'
7+
tags:
8+
- 'v*'
59
pull_request:
610

711
jobs:
@@ -16,6 +20,7 @@ jobs:
1620
path: |
1721
~/.gradle/caches/modules-2
1822
~/.gradle/wrapper/dists
23+
./.gradle/paperweight_cache
1924
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts', '**/gradle.properties', '**/gradle/wrapper/gradle-wrapper.properties') }}
2025
restore-keys: |
2126
${{ runner.os }}-gradle-
@@ -29,10 +34,10 @@ jobs:
2934
sudo rm -f ~/.gradle/caches/modules-2/modules-2.lock
3035
sudo rm -f ~/.gradle/caches/modules-2/gc.properties
3136
32-
# TODO:
33-
# - name: Upload the built artifact
34-
# uses: actions/upload-artifact@v2
35-
# with:
36-
# name: ${{ steps.exec.outputs.jar }}
37-
# path: build/libs/${{ steps.exec.outputs.jar }}
38-
# if-no-files-found: error
37+
- name: Create release if this is a tagged workflow
38+
uses: ncipollo/release-action@v1
39+
if: startsWith(github.ref, 'refs/tags/')
40+
with:
41+
artifacts: build/libs/${{ steps.exec.outputs.paperclip }}
42+
name: PaperX ${{ steps.exec.outputs.version }}
43+
token: ${{ secrets.GITHUB_TOKEN }}

build.gradle.kts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@ import io.papermc.paperweight.util.constants.PAPERCLIP_CONFIG
22

33
plugins {
44
java
5+
id("com.palantir.git-version") version "0.12.3"
56
id("com.github.johnrengelman.shadow") version "7.1.1"
67
id("io.papermc.paperweight.patcher") version "1.3.4"
78
}
89

10+
val versionDetails: groovy.lang.Closure<com.palantir.gradle.gitversion.VersionDetails> by extra
11+
val git = versionDetails()
12+
13+
group = "dev.fiki.paperx"
14+
version = "${providers.gradleProperty("mcVersion").get()}-${git.lastTag.substring(1)}.r${git.commitDistance}"
15+
16+
val isCiBuilding = System.getenv()["CI"] == "true"
17+
918
repositories {
1019
mavenCentral()
1120
maven("https://papermc.io/repo/repository/maven-public/") {
@@ -64,3 +73,14 @@ paperweight {
6473
}
6574
}
6675
}
76+
77+
val actionsTask by tasks.register("createGitHubActionsVars") {
78+
onlyIf { isCiBuilding }
79+
doFirst {
80+
println("::set-output name=paperclip::${tasks.createReobfPaperclipJar.get().outputZip.get().asFile.name}")
81+
println("::set-output name=bundler::${tasks.createReobfBundlerJar.get().outputZip.get().asFile.name}")
82+
println("::set-output name=version::${project.version}")
83+
}
84+
}
85+
86+
tasks.createReobfPaperclipJar { finalizedBy(actionsTask) }

docker-compose.ci.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ services:
55
build:
66
context: .
77
dockerfile: ./Dockerfile
8-
container_name: jdk-slim-git
98
environment:
109
- CI=${CI:-}
1110
volumes:
@@ -19,14 +18,13 @@ services:
1918
- .git/:/opt/build/.git/:ro
2019
# paperweight cache contains files that save the absolute path,
2120
# so we create a special volume to cache this directory
22-
- paperweight_cache:/opt/build/.gradle/caches/paperweight/
21+
# NOTE: a named volume would be better for this, but github actions does
22+
# not allow you to cache /var/lib/docker/volumes
23+
- ./.gradle/paperweight_cache/:/opt/build/.gradle/caches/paperweight/:Z
2324
# mount working directory
2425
- ./:/opt/build:Z
2526
working_dir: /opt/build
2627
# these two gradle tasks must be run independently, otherwise it will fail
2728
command: bash -c 'set -x
28-
&& ./gradlew --no-daemon applyPatches --stacktrace
29-
&& ./gradlew --no-daemon createReobfPaperclipJar --stacktrace'
30-
31-
volumes:
32-
paperweight_cache:
29+
&& ./gradlew --no-daemon applyPatches --stacktrace
30+
&& ./gradlew --no-daemon createReobfPaperclipJar --stacktrace'

gradle.properties

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
group=dev.fiki.paperx
2-
version=1.18.1-R0.1-SNAPSHOT
3-
41
mcVersion=1.18.1
52
packageVersion=1_18_R1
63
paperRef=a8f2d6749189f58b131fb077b7961b31df5f8005

scripts/cibuild

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
1717
if [[ "${1:-}" == "--help" ]]; then
1818
usage
1919
else
20+
# create .gradle with correct user permissions
21+
# docker daemon may otherwise create this directory with root ownership
22+
mkdir -p .gradle
23+
2024
# if mounting the hosts cache folder, gradle inside the container will try and
2125
# acquire a file lock that the host machine may already be holding. this will
2226
# result in the container hanging indefinitely. stopping any existing daemons

0 commit comments

Comments
 (0)