|
3 | 3 | push: |
4 | 4 | pull_request_target: |
5 | 5 | types: [labeled] |
| 6 | + |
| 7 | +env: |
| 8 | + JAVA_VERSION: 25 |
| 9 | + |
6 | 10 | jobs: |
7 | 11 | build: |
8 | 12 | name: Build and Test |
9 | 13 | runs-on: macos-latest |
| 14 | + permissions: |
| 15 | + id-token: write # Required for the attestations step |
| 16 | + attestations: write # Required for the attestations step |
| 17 | + contents: read |
10 | 18 | steps: |
11 | | - - uses: actions/checkout@v5 |
12 | | - - uses: actions/setup-java@v5 |
| 19 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 20 | + - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 |
13 | 21 | with: |
14 | 22 | distribution: 'temurin' |
15 | | - java-version: 24 |
| 23 | + java-version: ${{ env.JAVA_VERSION }} |
16 | 24 | cache: 'maven' |
17 | 25 | - name: Ensure to use tagged version |
18 | 26 | if: startsWith(github.ref, 'refs/tags/') |
19 | | - shell: bash |
20 | | - run: | |
21 | | - mvn -B versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/} |
| 27 | + run: ./mvnw versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/} |
22 | 28 | - name: Build and Test |
23 | | - id: buildAndTest |
24 | | - run: mvn -B clean install |
25 | | - - uses: actions/upload-artifact@v4 |
| 29 | + run: ./mvnw -B verify --no-transfer-progress |
| 30 | + - name: Attest |
| 31 | + if: startsWith(github.ref, 'refs/tags/') |
| 32 | + uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0 |
| 33 | + with: |
| 34 | + subject-path: | |
| 35 | + target/*.jar |
| 36 | + target/*.pom |
| 37 | + - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
26 | 38 | with: |
27 | 39 | name: artifacts |
28 | 40 | path: target/*.jar |
29 | | - - name: Create Release |
30 | | - uses: softprops/action-gh-release@v2 |
| 41 | + |
| 42 | + deploy-central: |
| 43 | + name: Deploy to Maven Central |
| 44 | + runs-on: macos-latest |
| 45 | + permissions: |
| 46 | + contents: read |
| 47 | + needs: [build] |
| 48 | + if: github.repository_owner == 'cryptomator' && (startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.message, '[deploy]')) |
| 49 | + steps: |
| 50 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 51 | + - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 |
| 52 | + with: |
| 53 | + distribution: 'temurin' |
| 54 | + java-version: ${{ env.JAVA_VERSION }} |
| 55 | + cache: 'maven' |
| 56 | + server-id: central |
| 57 | + server-username: MAVEN_CENTRAL_USERNAME |
| 58 | + server-password: MAVEN_CENTRAL_PASSWORD |
| 59 | + - name: Ensure to use tagged version |
31 | 60 | if: startsWith(github.ref, 'refs/tags/') |
| 61 | + run: ./mvnw versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/} |
| 62 | + - name: Verify project version is -SNAPSHOT |
| 63 | + if: startsWith(github.ref, 'refs/tags/') == false |
| 64 | + run: | |
| 65 | + PROJECT_VERSION=$(./mvnw help:evaluate "-Dexpression=project.version" -q -DforceStdout) |
| 66 | + test "${PROJECT_VERSION: -9}" = "-SNAPSHOT" |
| 67 | + - name: Deploy to Maven Central |
| 68 | + run: ./mvnw deploy -B -DskipTests -Psign,deploy-central --no-transfer-progress |
| 69 | + env: |
| 70 | + MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} |
| 71 | + MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} |
| 72 | + MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }} |
| 73 | + MAVEN_GPG_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import |
| 74 | + MAVEN_GPG_KEY_FINGERPRINT: ${{ vars.RELEASES_GPG_KEY_FINGERPRINT }} |
| 75 | + |
| 76 | + deploy-github: |
| 77 | + name: Deploy to GitHub Packages |
| 78 | + runs-on: macos-latest |
| 79 | + permissions: |
| 80 | + packages: write # Required for the deploy to GitHub Packages step |
| 81 | + contents: read |
| 82 | + needs: [build] |
| 83 | + if: github.repository_owner == 'cryptomator' && (startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.message, '[deploy]')) |
| 84 | + steps: |
| 85 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 86 | + - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 |
| 87 | + with: |
| 88 | + java-version: ${{ env.JAVA_VERSION }} |
| 89 | + distribution: 'temurin' |
| 90 | + cache: 'maven' |
| 91 | + - name: Ensure to use tagged version |
| 92 | + if: startsWith(github.ref, 'refs/tags/') |
| 93 | + run: ./mvnw versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/} |
| 94 | + - name: Verify project version is -SNAPSHOT |
| 95 | + if: startsWith(github.ref, 'refs/tags/') == false |
| 96 | + run: | |
| 97 | + PROJECT_VERSION=$(./mvnw help:evaluate "-Dexpression=project.version" -q -DforceStdout) |
| 98 | + test "${PROJECT_VERSION: -9}" = "-SNAPSHOT" |
| 99 | + - name: Deploy to GitHub Packages |
| 100 | + run: ./mvnw deploy -B -DskipTests -Psign,deploy-github --no-transfer-progress |
| 101 | + env: |
| 102 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 103 | + MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }} |
| 104 | + MAVEN_GPG_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import |
| 105 | + MAVEN_GPG_KEY_FINGERPRINT: ${{ vars.RELEASES_GPG_KEY_FINGERPRINT }} |
| 106 | + |
| 107 | + release: |
| 108 | + name: Release |
| 109 | + runs-on: ubuntu-latest |
| 110 | + permissions: |
| 111 | + contents: write # Required for the release step |
| 112 | + needs: [deploy-central, deploy-github] |
| 113 | + if: startsWith(github.ref, 'refs/tags/') |
| 114 | + steps: |
| 115 | + - name: Create Release |
| 116 | + uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0 |
32 | 117 | with: |
33 | 118 | prerelease: true |
34 | 119 | token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }} |
|
0 commit comments