|
1 | 1 | name: Build |
2 | 2 | on: |
3 | 3 | push: |
| 4 | + pull_request_target: |
| 5 | + types: [labeled] |
| 6 | + |
| 7 | +env: |
| 8 | + JAVA_VERSION: 25 |
4 | 9 |
|
5 | 10 | jobs: |
6 | 11 | build: |
7 | 12 | name: Build and Test |
8 | 13 | runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + id-token: write # Required for the attestations step |
| 16 | + attestations: write # Required for the attestations step |
9 | 17 | steps: |
10 | 18 | - uses: actions/checkout@v5 |
11 | 19 | - uses: actions/setup-java@v5 |
12 | 20 | with: |
13 | 21 | distribution: 'temurin' |
14 | | - java-version: 24 |
| 22 | + java-version: ${{ env.JAVA_VERSION }} |
15 | 23 | cache: 'maven' |
16 | 24 | - name: Ensure to use tagged version |
17 | 25 | if: startsWith(github.ref, 'refs/tags/') |
18 | | - shell: bash |
19 | | - run: | |
20 | | - mvn -B versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/} |
| 26 | + run: mvn versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/} |
21 | 27 | - name: Build and Test |
22 | | - id: buildAndTest |
23 | | - run: mvn -B clean verify |
24 | | - - uses: actions/upload-artifact@v4 |
| 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 |
| 36 | + - uses: actions/upload-artifact@v5 |
25 | 37 | with: |
26 | 38 | name: artifacts |
27 | 39 | 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: |
28 | 106 | - name: Create Release |
29 | 107 | uses: softprops/action-gh-release@v2 |
30 | | - if: startsWith(github.ref, 'refs/tags/') |
31 | 108 | with: |
32 | 109 | prerelease: true |
33 | 110 | token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }} |
|
0 commit comments