Skip to content

Commit 1bddb34

Browse files
Merge pull request #74
Refactor `.github/workflows/build.yml`, enabling SNAPSHOT publishing
2 parents e3d50e9 + bbded71 commit 1bddb34

3 files changed

Lines changed: 82 additions & 64 deletions

File tree

.github/workflows/build.yml

Lines changed: 82 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,108 @@ on:
33
push:
44
pull_request_target:
55
types: [labeled]
6+
7+
env:
8+
JAVA_VERSION: 25
9+
610
jobs:
711
build:
812
name: Build and Test
913
runs-on: ubuntu-latest
10-
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
14+
permissions:
15+
id-token: write # Required for the attestations step
16+
attestations: write # Required for the attestations step
1117
steps:
1218
- uses: actions/checkout@v5
1319
- uses: actions/setup-java@v5
1420
with:
1521
distribution: 'temurin'
16-
java-version: 25
22+
java-version: ${{ env.JAVA_VERSION }}
1723
cache: 'maven'
1824
- name: Ensure to use tagged version
1925
if: startsWith(github.ref, 'refs/tags/')
2026
run: mvn versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/}
2127
- name: Build and Test
22-
id: buildAndTest
23-
run: mvn -B clean install
28+
run: mvn -B verify --no-transfer-progress
29+
- name: Attest
30+
if: startsWith(github.ref, 'refs/tags/')
31+
uses: actions/attest-build-provenance@v3
32+
with:
33+
subject-path: |
34+
target/*.jar
35+
target/*.pom
2436
- uses: actions/upload-artifact@v4
2537
with:
2638
name: artifacts
2739
path: target/*.jar
40+
41+
deploy-central:
42+
name: Deploy to Maven Central
43+
runs-on: ubuntu-latest
44+
permissions: {}
45+
needs: [build]
46+
if: github.repository_owner == 'cryptomator' && (startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.message, '[deploy]'))
47+
steps:
48+
- uses: actions/checkout@v5
49+
- uses: actions/setup-java@v5
50+
with:
51+
distribution: 'temurin'
52+
java-version: ${{ env.JAVA_VERSION }}
53+
cache: 'maven'
54+
server-id: central
55+
server-username: MAVEN_CENTRAL_USERNAME
56+
server-password: MAVEN_CENTRAL_PASSWORD
57+
- name: Verify project version matches tag
58+
if: startsWith(github.ref, 'refs/tags/')
59+
run: |
60+
PROJECT_VERSION=$(mvn help:evaluate "-Dexpression=project.version" -q -DforceStdout)
61+
test "$PROJECT_VERSION" = "${GITHUB_REF##*/}"
62+
- name: Deploy to Maven Central
63+
run: mvn deploy -B -DskipTests -Psign,deploy-central --no-transfer-progress
64+
env:
65+
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
66+
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
67+
MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
68+
MAVEN_GPG_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
69+
MAVEN_GPG_KEY_FINGERPRINT: ${{ vars.RELEASES_GPG_KEY_FINGERPRINT }}
70+
71+
deploy-github:
72+
name: Deploy to GitHub Packages
73+
runs-on: ubuntu-latest
74+
permissions:
75+
packages: write # Required for the deploy to GitHub Packages step
76+
needs: [build]
77+
if: github.repository_owner == 'cryptomator' && (startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.message, '[deploy]'))
78+
steps:
79+
- uses: actions/checkout@v5
80+
- uses: actions/setup-java@v5
81+
with:
82+
java-version: ${{ env.JAVA_VERSION }}
83+
distribution: 'temurin'
84+
cache: 'maven'
85+
- name: Verify project version matches tag
86+
if: startsWith(github.ref, 'refs/tags/')
87+
run: |
88+
PROJECT_VERSION=$(mvn help:evaluate "-Dexpression=project.version" -q -DforceStdout)
89+
test "$PROJECT_VERSION" = "${GITHUB_REF##*/}"
90+
- name: Deploy to GitHub Packages
91+
run: mvn deploy -B -DskipTests -Psign,deploy-github --no-transfer-progress
92+
env:
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94+
MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
95+
MAVEN_GPG_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
96+
MAVEN_GPG_KEY_FINGERPRINT: ${{ vars.RELEASES_GPG_KEY_FINGERPRINT }}
97+
98+
release:
99+
name: Release
100+
runs-on: ubuntu-latest
101+
permissions:
102+
contents: write # Required for the release step
103+
needs: [deploy-central, deploy-github]
104+
if: startsWith(github.ref, 'refs/tags/')
105+
steps:
28106
- name: Create Release
29107
uses: softprops/action-gh-release@v2
30-
if: startsWith(github.ref, 'refs/tags/')
31108
with:
32109
prerelease: true
33110
token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }}

.github/workflows/publish-central.yml

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

.github/workflows/publish-github.yml

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

0 commit comments

Comments
 (0)