Skip to content

Commit 8328ee6

Browse files
authored
use separate workflows for building only and also publishing (#3386)
1 parent 0153c90 commit 8328ee6

3 files changed

Lines changed: 67 additions & 13 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Used when a commit is pushed to the repository
2+
# This makes use of caching for faster builds and uploads the resulting artifacts
3+
name: build-commit
4+
5+
on:
6+
push:
7+
branches:
8+
- dev
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
environment: staging
14+
15+
steps:
16+
- name: Extract current branch name
17+
shell: bash
18+
# bash pattern expansion to grab branch name without slashes
19+
run: ref="${GITHUB_REF#refs/heads/}" && echo "branch=${ref////-}" >> $GITHUB_OUTPUT
20+
id: ref
21+
22+
- name: Checkout sources
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Java 21
26+
uses: actions/setup-java@v4
27+
with:
28+
distribution: temurin
29+
java-version: 21
30+
31+
- name: Setup Gradle
32+
uses: gradle/actions/setup-gradle@v4
33+
with:
34+
cache-read-only: false
35+
36+
- name: Execute Gradle build
37+
run: ./gradlew build
38+
39+
- name: Upload artifacts
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: sodium-artifacts-${{ steps.ref.outputs.branch }}
43+
path: build/mods/*.jar
44+
45+
- name: Publish Release Snapshot to CaffeineMC Maven
46+
env:
47+
ORG_GRADLE_PROJECT_caffeineMCMavenUsername: ${{ secrets.CAFFEINEMC_MAVEN_USERNAME }}
48+
ORG_GRADLE_PROJECT_caffeineMCMavenPassword: ${{ secrets.CAFFEINEMC_MAVEN_PASSWORD }}
49+
if: ${{ env.ORG_GRADLE_PROJECT_caffeineMCMavenUsername != '' && env.ORG_GRADLE_PROJECT_caffeineMCMavenPassword != '' }}
50+
run: ./gradlew publishAllPublicationsToCaffeineMCRepository

.github/workflows/build-commit.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22
# This makes use of caching for faster builds and uploads the resulting artifacts
33
name: build-commit
44

5-
on: [ push ]
5+
on:
6+
push:
7+
branches-ignore:
8+
- dev
69

710
jobs:
811
build:
912
runs-on: ubuntu-latest
10-
environment:
11-
name: staging
1213

1314
steps:
1415
- name: Extract current branch name
1516
shell: bash
1617
# bash pattern expansion to grab branch name without slashes
1718
run: ref="${GITHUB_REF#refs/heads/}" && echo "branch=${ref////-}" >> $GITHUB_OUTPUT
1819
id: ref
20+
1921
- name: Checkout sources
2022
uses: actions/checkout@v4
2123

@@ -38,10 +40,3 @@ jobs:
3840
with:
3941
name: sodium-artifacts-${{ steps.ref.outputs.branch }}
4042
path: build/mods/*.jar
41-
42-
- name: Publish Commit Snapshot to CaffeineMC Maven
43-
env:
44-
ORG_GRADLE_PROJECT_caffeineMCMavenUsername: ${{ secrets.CAFFEINEMC_MAVEN_USERNAME }}
45-
ORG_GRADLE_PROJECT_caffeineMCMavenPassword: ${{ secrets.CAFFEINEMC_MAVEN_PASSWORD }}
46-
if: ${{ env.ORG_GRADLE_PROJECT_caffeineMCMavenUsername != '' && env.ORG_GRADLE_PROJECT_caffeineMCMavenPassword != '' }}
47-
run: ./gradlew publishAllPublicationsToCaffeineMCRepository

.github/workflows/build-pull-request.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,17 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- uses: actions/checkout@v4
13-
- uses: actions/setup-java@v4
12+
- name: Extract current branch name
13+
shell: bash
14+
# bash pattern expansion to grab branch name without slashes
15+
run: ref="${GITHUB_REF#refs/heads/}" && echo "branch=${ref////-}" >> $GITHUB_OUTPUT
16+
id: ref
17+
18+
- name: Checkout sources
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Java 21
22+
uses: actions/setup-java@v4
1423
with:
1524
distribution: temurin
1625
java-version: 21
@@ -27,4 +36,4 @@ jobs:
2736
uses: actions/upload-artifact@v4
2837
with:
2938
name: sodium-artifacts-${{ steps.ref.outputs.branch }}
30-
path: build/mods/*.jar
39+
path: build/mods/*.jar

0 commit comments

Comments
 (0)