Skip to content

Commit aa113b3

Browse files
committed
Update workflows and publishing to use generation system
1 parent 56845e9 commit aa113b3

File tree

8 files changed

+362
-212
lines changed

8 files changed

+362
-212
lines changed

.github/workflows/build_pr.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"jobs": {
3+
"build": {
4+
"runs-on": "ubuntu-22.04",
5+
"steps": [
6+
{
7+
"name": "Setup Java",
8+
"run": "echo \"JAVA_HOME=$JAVA_HOME_17_X64\" >> \"$GITHUB_ENV\""
9+
},
10+
{
11+
"with": {
12+
"fetch-depth": "0",
13+
"persist-credentials": "false"
14+
},
15+
"name": "Checkout",
16+
"uses": "actions/checkout@v4"
17+
},
18+
{
19+
"with": {
20+
"path": "**/.gradle/loom-cache",
21+
"key": "${{ runner.os }}-gradle-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }}",
22+
"restore-keys": "${{ runner.os }}-gradle-"
23+
},
24+
"name": "Cache",
25+
"uses": "actions/cache/restore@v3"
26+
},
27+
{
28+
"with": {
29+
"cache-read-only": true,
30+
"gradle-home-cache-cleanup": true
31+
},
32+
"name": "Setup Gradle",
33+
"uses": "gradle/gradle-build-action@v2"
34+
},
35+
{
36+
"name": "Build",
37+
"run": "./gradlew checkLicenses build",
38+
"id": "build",
39+
"env": {
40+
"PR_NUMBER": "${{ github.event.pull_request.number }}"
41+
}
42+
},
43+
{
44+
"name": "Publish",
45+
"run": "./gradlew publish",
46+
"id": "publish",
47+
"env": {
48+
"PR_NUMBER": "${{ github.event.pull_request.number }}"
49+
}
50+
},
51+
{
52+
"with": {
53+
"name": "artifacts",
54+
"path": "build/repo"
55+
},
56+
"name": "Archive Publishable Artifacts",
57+
"uses": "actions/upload-artifact@v3"
58+
}
59+
]
60+
}
61+
},
62+
"name": "Build PR",
63+
"concurrency": "ci-${{ github.ref }}",
64+
"on": {
65+
"pull_request": {
66+
67+
}
68+
}
69+
}

.github/workflows/publish_pr.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"jobs": {
3+
"publish": {
4+
"runs-on": "ubuntu-22.04",
5+
"steps": [
6+
{
7+
"with": {
8+
"repository": "lukebemish/artifact-sync",
9+
"ref": "refs/heads/main",
10+
"persist-credentials": false
11+
},
12+
"name": "Checkout Artifact Sync",
13+
"uses": "actions/checkout@v4"
14+
},
15+
{
16+
"run": "mkdir repo"
17+
},
18+
{
19+
"with": {
20+
"script": "const pull_requests = ${{ toJSON(github.event.workflow_run.pull_requests) }};\nif (!pull_requests.length) {\n return core.error(\"This workflow doesn't match any pull requests!\");\n}\nlet allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({\n owner: context.repo.owner,\n repo: context.repo.repo,\n run_id: context.payload.workflow_run.id,\n});\nlet matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {\n return artifact.name == \"artifacts\"\n})[0];\nlet download = await github.rest.actions.downloadArtifact({\n owner: context.repo.owner,\n repo: context.repo.repo,\n artifact_id: matchArtifact.id,\n archive_format: 'zip',\n});\nlet fs = require('fs');\nfs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/repo.zip`, Buffer.from(download.data));"
21+
},
22+
"name": "Download Artifacts",
23+
"uses": "actions/github-script@v6"
24+
},
25+
{
26+
"name": "Unpack Artifacts",
27+
"run": "unzip repo.zip -d repo"
28+
},
29+
{
30+
"name": "Publish Artifacts",
31+
"run": "python3 run.py",
32+
"env": {
33+
"MAVEN_USER": "github",
34+
"MAVEN_PASSWORD": "${{ secrets.PR_MAVEN_PASSWORD }}",
35+
"MAVEN_URL": "https://maven.lukebemish.dev/pullrequests/",
36+
"ALLOWED_VERSION": "*-pr${{ github.event.workflow_run.pull_requests[0].number }}",
37+
"ALLOWED_PATHS": "dev/lukebemish/dynamicassetgenerator/dynamicassetgenerator-*"
38+
}
39+
}
40+
],
41+
"if": "${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}"
42+
}
43+
},
44+
"name": "Publish PR",
45+
"concurrency": "ci-${{ github.ref }}",
46+
"on": {
47+
"workflow_run": {
48+
"types": [
49+
"completed"
50+
],
51+
"workflows": [
52+
"Build PR"
53+
]
54+
}
55+
}
56+
}

.github/workflows/pullrequest.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 101 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,101 @@
1-
name: Release
2-
concurrency: ci-${{ github.ref }}
3-
on:
4-
workflow_dispatch:
5-
jobs:
6-
build:
7-
runs-on: ubuntu-22.04
8-
steps:
9-
- name: Setup Java
10-
run: |
11-
echo "JAVA_HOME=$JAVA_HOME_17_X64" >> "$GITHUB_ENV"
12-
- uses: actions/checkout@v4
13-
with:
14-
fetch-depth: 0
15-
- uses: fregante/setup-git-user@v2
16-
- uses: actions/cache@v3
17-
with:
18-
path: |
19-
**/.gradle/loom-cache
20-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }}
21-
restore-keys: ${{ runner.os }}-gradle-
22-
- uses: gradle/gradle-build-action@v2
23-
name: Setup Gradle
24-
with:
25-
gradle-home-cache-cleanup: true
26-
- name: Tag Release
27-
run: |
28-
./gradlew tagRelease
29-
- name: Build
30-
run: |
31-
./gradlew checkLicenses build prepareJavadoc
32-
- uses: andreiio/[email protected]
33-
with:
34-
args: copy build/prepareJavadoc r2:javadoc-lukebemish-dev
35-
env:
36-
RCLONE_CONFIG_R2_TYPE: s3
37-
RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.JAVADOC_ACCESS_KEY_ID }}
38-
RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.JAVADOC_SECRET_ACCESS_KEY }}
39-
RCLONE_CONFIG_R2_PROVIDER: Cloudflare
40-
RCLONE_CONFIG_R2_REGION: auto
41-
RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.JAVADOC_ENDPOINT }}
42-
RCLONE_CONFIG_R2_ACL: private
43-
- name: Publish
44-
run: |
45-
./gradlew publish curseforge modrinth
46-
env:
47-
MAVEN_USER: github
48-
MAVEN_PASSWORD: ${{ secrets.RELEASE_MAVEN_PASSWORD }}
49-
CURSEFORGE_KEY: ${{ secrets.CURSEFORGE_KEY }}
50-
MODRINTH_KEY: ${{ secrets.MODRINTH_KEY }}
51-
MAVEN_URL: https://maven.lukebemish.dev/releases/
52-
- run: |
53-
git push
54-
git push --tags
1+
{
2+
"jobs": {
3+
"build": {
4+
"runs-on": "ubuntu-22.04",
5+
"permissions": {
6+
"contents": "write"
7+
},
8+
"steps": [
9+
{
10+
"name": "Setup Java",
11+
"run": "echo \"JAVA_HOME=$JAVA_HOME_17_X64\" >> \"$GITHUB_ENV\""
12+
},
13+
{
14+
"with": {
15+
"fetch-depth": "0"
16+
},
17+
"name": "Checkout",
18+
"uses": "actions/checkout@v4"
19+
},
20+
{
21+
"with": {
22+
"path": "**/.gradle/loom-cache",
23+
"key": "${{ runner.os }}-gradle-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }}",
24+
"restore-keys": "${{ runner.os }}-gradle-"
25+
},
26+
"name": "Cache",
27+
"uses": "actions/cache@v3"
28+
},
29+
{
30+
"with": {
31+
"gradle-home-cache-cleanup": true
32+
},
33+
"name": "Setup Gradle",
34+
"uses": "gradle/gradle-build-action@v2"
35+
},
36+
{
37+
"name": "tagRelease",
38+
"run": "./gradlew ",
39+
"id": "tagrelease",
40+
"env": {
41+
"RELEASE_MAVEN_PASSWORD": "${{ secrets.RELEASE_MAVEN_PASSWORD }}",
42+
"RELEASE_MAVEN_USER": "github",
43+
"RELEASE_MAVEN_URL": "https://maven.lukebemish.dev/releases/",
44+
"CURSEFORGE_KEY": "${{ secrets.CURSEFORGE_KEY }}",
45+
"MODRINTH_KEY": "${{ secrets.MODRINTH_KEY }}"
46+
}
47+
},
48+
{
49+
"name": "Build",
50+
"run": "./gradlew checkLicenses build prepareJavadoc",
51+
"id": "build",
52+
"env": {
53+
"RELEASE_MAVEN_PASSWORD": "${{ secrets.RELEASE_MAVEN_PASSWORD }}",
54+
"RELEASE_MAVEN_USER": "github",
55+
"RELEASE_MAVEN_URL": "https://maven.lukebemish.dev/releases/",
56+
"CURSEFORGE_KEY": "${{ secrets.CURSEFORGE_KEY }}",
57+
"MODRINTH_KEY": "${{ secrets.MODRINTH_KEY }}"
58+
}
59+
},
60+
{
61+
"with": {
62+
"args": "copy build/prepareJavadoc r2:javadoc-lukebemish-dev"
63+
},
64+
"name": "Upload Javadoc",
65+
"uses": "andreiio/[email protected]",
66+
"env": {
67+
"RCLONE_CONFIG_R2_TYPE": "s3",
68+
"RCLONE_CONFIG_R2_ACCESS_KEY_ID": "${{ secrets.JAVADOC_ACCESS_KEY_ID }}",
69+
"RCLONE_CONFIG_R2_SECRET_ACCESS_KEY": "${{ secrets.JAVADOC_SECRET_ACCESS_KEY }}",
70+
"RCLONE_CONFIG_R2_ENDPOINT": "${{ secrets.JAVADOC_ENDPOINT }}",
71+
"RCLONE_CONFIG_R2_PROVIDER": "Cloudflare",
72+
"RCLONE_CONFIG_R2_REGION": "auto",
73+
"RCLONE_CONFIG_R2_ACL": "private"
74+
}
75+
},
76+
{
77+
"name": "Publish",
78+
"run": "./gradlew publish modrinth curseforge",
79+
"id": "publish",
80+
"env": {
81+
"RELEASE_MAVEN_PASSWORD": "${{ secrets.RELEASE_MAVEN_PASSWORD }}",
82+
"RELEASE_MAVEN_USER": "github",
83+
"RELEASE_MAVEN_URL": "https://maven.lukebemish.dev/releases/",
84+
"CURSEFORGE_KEY": "${{ secrets.CURSEFORGE_KEY }}",
85+
"MODRINTH_KEY": "${{ secrets.MODRINTH_KEY }}"
86+
}
87+
},
88+
{
89+
"run": "git push && git push --tags"
90+
}
91+
]
92+
}
93+
},
94+
"name": "Release",
95+
"concurrency": "ci-${{ github.ref }}",
96+
"on": {
97+
"workflow_dispatch": {
98+
99+
}
100+
}
101+
}

0 commit comments

Comments
 (0)