Skip to content

Commit 2a82e48

Browse files
authored
Merge pull request #104 from cryptomator/feature/refactor-ci
Refactor CI
2 parents b448113 + 748def7 commit 2a82e48

6 files changed

Lines changed: 138 additions & 71 deletions

File tree

.github/workflows/build.yml

Lines changed: 126 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,31 @@ 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
14+
permissions:
15+
contents: read
16+
id-token: write # OIDC token for the attestations step
17+
attestations: write # Required for the attestations step
18+
outputs:
19+
sha256: ${{ steps.checksums.outputs.sha256 }}
1020
steps:
11-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1222
with:
13-
fetch-depth: 0
14-
- uses: actions/setup-java@v4
23+
fetch-depth: 0 # deep fetch for better sonarcloud analysis
24+
- uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
1525
with:
16-
java-version: 23
1726
distribution: 'temurin'
27+
java-version: ${{ env.JAVA_VERSION }}
1828
cache: 'maven'
1929
- name: Cache SonarCloud packages
20-
uses: actions/cache@v4
30+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
2131
with:
2232
path: ~/.sonar/cache
2333
key: ${{ runner.os }}-sonar
@@ -26,9 +36,8 @@ jobs:
2636
if: startsWith(github.ref, 'refs/tags/')
2737
run: ./mvnw versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/}
2838
- name: Build and Test
29-
id: buildAndTest
3039
run: >
31-
./mvnw -B verify
40+
./mvnw -B verify --no-transfer-progress
3241
jacoco:report
3342
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
3443
-Pcoverage
@@ -38,14 +47,121 @@ jobs:
3847
env:
3948
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
4049
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
41-
- uses: actions/upload-artifact@v4
50+
- name: Calculate Checksums
51+
id: checksums
52+
run: |
53+
{
54+
echo 'sha256<<EOF'
55+
shasum -a256 target/*.jar
56+
echo EOF
57+
} >> $GITHUB_OUTPUT
58+
- name: Attest
59+
if: startsWith(github.ref, 'refs/tags/')
60+
uses: actions/attest-build-provenance@00014ed6ed5efc5b1ab7f7f34a39eb55d41aa4f8 # v3.1.0
61+
with:
62+
subject-path: |
63+
target/*.jar
64+
target/*.pom
65+
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
4266
with:
4367
name: artifacts
4468
path: target/*.jar
45-
- name: Create Release
46-
uses: softprops/action-gh-release@v2
69+
70+
deploy-central:
71+
name: Deploy to Maven Central
72+
runs-on: ubuntu-latest
73+
permissions:
74+
id-token: write # OIDC token for sigstore signing
75+
contents: read # Required for sigstore signing
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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
80+
- uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
81+
with:
82+
distribution: 'temurin'
83+
java-version: ${{ env.JAVA_VERSION }}
84+
cache: 'maven'
85+
server-id: central
86+
server-username: MAVEN_CENTRAL_USERNAME
87+
server-password: MAVEN_CENTRAL_PASSWORD
88+
- name: Enforce to use tagged version
4789
if: startsWith(github.ref, 'refs/tags/')
90+
run: ./mvnw versions:set -B -DnewVersion="${GITHUB_REF##*/}"
91+
- name: Verify project version is -SNAPSHOT
92+
if: startsWith(github.ref, 'refs/tags/') == false
93+
run: |
94+
PROJECT_VERSION=$(./mvnw help:evaluate "-Dexpression=project.version" -q -DforceStdout)
95+
test "${PROJECT_VERSION: -9}" = "-SNAPSHOT"
96+
- name: Deploy to Maven Central
97+
run: ./mvnw deploy -B -DskipTests -Psign,deploy-central --no-transfer-progress
98+
env:
99+
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
100+
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
101+
MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
102+
MAVEN_GPG_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
103+
MAVEN_GPG_KEY_FINGERPRINT: ${{ vars.RELEASES_GPG_KEY_FINGERPRINT }}
104+
105+
deploy-github:
106+
name: Deploy to GitHub Packages
107+
runs-on: ubuntu-latest
108+
permissions:
109+
packages: write # Required for the deploy to GitHub Packages step
110+
id-token: write # OIDC token for sigstore signing
111+
contents: read # Required for sigstore signing
112+
needs: [build]
113+
if: github.repository_owner == 'cryptomator' && (startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.message, '[deploy]'))
114+
steps:
115+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
116+
- uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
117+
with:
118+
java-version: ${{ env.JAVA_VERSION }}
119+
distribution: 'temurin'
120+
cache: 'maven'
121+
- name: Enforce to use tagged version
122+
if: startsWith(github.ref, 'refs/tags/')
123+
run: ./mvnw versions:set -B -DnewVersion="${GITHUB_REF##*/}"
124+
- name: Verify project version is -SNAPSHOT
125+
if: startsWith(github.ref, 'refs/tags/') == false
126+
run: |
127+
PROJECT_VERSION=$(./mvnw help:evaluate "-Dexpression=project.version" -q -DforceStdout)
128+
test "${PROJECT_VERSION: -9}" = "-SNAPSHOT"
129+
- name: Deploy to GitHub Packages
130+
run: ./mvnw deploy -B -DskipTests -Psign,deploy-github --no-transfer-progress
131+
env:
132+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133+
MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
134+
MAVEN_GPG_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
135+
MAVEN_GPG_KEY_FINGERPRINT: ${{ vars.RELEASES_GPG_KEY_FINGERPRINT }}
136+
137+
release:
138+
name: Release
139+
runs-on: ubuntu-latest
140+
permissions:
141+
contents: write # Required for the release step
142+
needs: [build, deploy-central, deploy-github]
143+
if: startsWith(github.ref, 'refs/tags/')
144+
steps:
145+
- name: Create Release
146+
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
48147
with:
49148
prerelease: true
50149
token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }}
51150
generate_release_notes: true
151+
body: |-
152+
### Changelog
153+
For a list of all notable changes, read the [changelog](/CHANGELOG.md).
154+
155+
### Maven Coordinates
156+
```xml
157+
<dependency>
158+
<groupId>org.cryptomator</groupId>
159+
<artifactId>cryptolib</artifactId>
160+
<version>${{ github.ref_name }}</version>
161+
</dependency>
162+
```
163+
164+
### Artifact Checksums
165+
```txt
166+
${{ needs.build.outputs.sha256 }}
167+
```

.github/workflows/codeql-analysis.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,20 @@ jobs:
1414
name: Analyse
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1818
with:
1919
fetch-depth: 2
20-
- uses: actions/setup-java@v4
20+
show-progress: false
21+
- uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
2122
with:
22-
java-version: 23
23+
java-version: 25
2324
distribution: 'temurin'
2425
cache: 'maven'
2526
- name: Initialize CodeQL
26-
uses: github/codeql-action/init@v3
27+
uses: github/codeql-action/init@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
2728
with:
2829
languages: java
2930
- name: Build and Test
3031
run: ./mvnw -B install -DskipTests
3132
- name: Perform CodeQL Analysis
32-
uses: github/codeql-action/analyze@v3
33+
uses: github/codeql-action/analyze@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7

.github/workflows/dependency-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ on:
1010

1111
jobs:
1212
check-dependencies:
13-
uses: skymatic/workflows/.github/workflows/run-dependency-check.yml@v3
13+
uses: skymatic/workflows/.github/workflows/run-dependency-check.yml@1074588008ae3326a2221ea451783280518f0366 # v3.0.1
1414
with:
1515
runner-os: 'ubuntu-latest'
1616
java-distribution: 'temurin'
17-
java-version: 23
17+
java-version: 25
1818
secrets:
1919
nvd-api-key: ${{ secrets.NVD_API_KEY }}
2020
ossindex-username: ${{ secrets.OSSINDEX_USERNAME }}

.github/workflows/publish-central.yml

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

.github/workflows/publish-github.yml

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

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ Changes to prior versions can be found on the [Github release page](https://gith
1111

1212
### Added
1313
- Changelog file
14-
- Maven wrapper script ([#103](https://github.com/cryptomator/cryptolib/pull/103))
14+
- Maven wrapper script ([#103](https://github.com/cryptomator/cryptolib/pull/103))
15+
16+
### Changed
17+
- Pin CI actions

0 commit comments

Comments
 (0)