diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0ed19b7c..66ddc1d6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,4 @@ name: Build - on: push: pull_request_target: @@ -13,18 +12,21 @@ jobs: name: Build and Test runs-on: ubuntu-latest permissions: - id-token: write # Required for the attestations step + contents: read + id-token: write # OIDC token for the attestations step attestations: write # Required for the attestations step - contents: write # Required for the release step + artifact-metadata: write # Required for the attestations step + outputs: + sha256: ${{ steps.checksums.outputs.sha256 }} steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - fetch-depth: 0 - show-progress: false + fetch-depth: 0 # deep fetch for better sonarcloud analysis + show-progress: false - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 with: - java-version: ${{ env.JAVA_VERSION }} distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} cache: 'maven' - name: Cache SonarCloud packages uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 @@ -34,10 +36,10 @@ jobs: restore-keys: ${{ runner.os }}-sonar - name: Ensure to use tagged version if: startsWith(github.ref, 'refs/tags/') - run: ./mvnw -B versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/} + run: ./mvnw versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/} - name: Build and Test run: > - ./mvnw -B verify + ./mvnw -B verify --no-transfer-progress jacoco:report org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Pcoverage @@ -47,9 +49,17 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - name: Calculate Checksums + id: checksums + run: | + { + echo 'sha256<> $GITHUB_OUTPUT - name: Attest if: startsWith(github.ref, 'refs/tags/') - uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0 + uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4.1.0 with: subject-path: | target/*.jar @@ -57,13 +67,105 @@ jobs: - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 with: name: artifacts - path: target/*.jar - - name: Create Release + path: | + target/*.jar + + + deploy-central: + name: Deploy to Maven Central + runs-on: ubuntu-latest + permissions: + id-token: write # OIDC token for sigstore signing + contents: read # Required for sigstore signing + needs: [build] + if: github.repository_owner == 'cryptomator' && (startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.message, '[deploy]')) + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 + with: + distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + cache: 'maven' + server-id: central + server-username: MAVEN_CENTRAL_USERNAME + server-password: MAVEN_CENTRAL_PASSWORD + - name: Enforce to use tagged version if: startsWith(github.ref, 'refs/tags/') + run: ./mvnw versions:set -B -DnewVersion="${GITHUB_REF##*/}" + - name: Verify project version is -SNAPSHOT + if: startsWith(github.ref, 'refs/tags/') == false + run: | + PROJECT_VERSION=$(./mvnw help:evaluate "-Dexpression=project.version" -q -DforceStdout) + test "${PROJECT_VERSION: -9}" = "-SNAPSHOT" + - name: Deploy to Maven Central + run: ./mvnw deploy -B -DskipTests -Psign,deploy-central --no-transfer-progress + env: + MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }} + MAVEN_GPG_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import + MAVEN_GPG_KEY_FINGERPRINT: ${{ vars.RELEASES_GPG_KEY_FINGERPRINT }} + + deploy-github: + name: Deploy to GitHub Packages + runs-on: ubuntu-latest + permissions: + packages: write # Required for the deploy to GitHub Packages step + id-token: write # OIDC token for sigstore signing + contents: read # Required for sigstore signing + needs: [build] + if: github.repository_owner == 'cryptomator' && (startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.message, '[deploy]')) + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: 'temurin' + cache: 'maven' + - name: Enforce to use tagged version + if: startsWith(github.ref, 'refs/tags/') + run: ./mvnw versions:set -B -DnewVersion="${GITHUB_REF##*/}" + - name: Verify project version is -SNAPSHOT + if: startsWith(github.ref, 'refs/tags/') == false + run: | + PROJECT_VERSION=$(./mvnw help:evaluate "-Dexpression=project.version" -q -DforceStdout) + test "${PROJECT_VERSION: -9}" = "-SNAPSHOT" + - name: Deploy to GitHub Packages + run: ./mvnw deploy -B -DskipTests -Psign,deploy-github --no-transfer-progress + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }} + MAVEN_GPG_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import + MAVEN_GPG_KEY_FINGERPRINT: ${{ vars.RELEASES_GPG_KEY_FINGERPRINT }} + + release: + name: Release + runs-on: ubuntu-latest + permissions: + contents: write # Required for the release step + needs: [build, deploy-central, deploy-github] + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Create Release uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0 with: prerelease: true token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }} generate_release_notes: true - body: | + body: |- + ### Changelog For a list of all notable changes, read the [changelog](/CHANGELOG.md). + + ### Maven Coordinates + ```xml + + org.cryptomator + cryptofs + ${{ github.ref_name }} + + ``` + + ### Artifact Checksums + ```txt + ${{ needs.build.outputs.sha256 }} + ``` \ No newline at end of file diff --git a/.github/workflows/publish-central.yml b/.github/workflows/publish-central.yml deleted file mode 100644 index 677c2cbd..00000000 --- a/.github/workflows/publish-central.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Publish to Maven Central -on: - release: - types: [published] -jobs: - publish: - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') # only allow publishing tagged versions - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 - with: - java-version: 25 - distribution: 'temurin' - cache: 'maven' - server-id: central - server-username: MAVEN_CENTRAL_USERNAME - server-password: MAVEN_CENTRAL_PASSWORD - - name: Enforce project version ${{ github.event.release.tag_name }} - run: ./mvnw versions:set -B -DnewVersion=${{ github.event.release.tag_name }} - - name: Deploy - run: ./mvnw deploy -B -DskipTests -Psign,deploy-central --no-transfer-progress - env: - MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} - MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} - MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }} - MAVEN_GPG_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} - MAVEN_GPG_KEY_FINGERPRINT: ${{ vars.RELEASES_GPG_KEY_FINGERPRINT }} \ No newline at end of file diff --git a/.github/workflows/publish-github.yml b/.github/workflows/publish-github.yml deleted file mode 100644 index f3484f40..00000000 --- a/.github/workflows/publish-github.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Publish to GitHub Packages -on: - release: - types: [published] -jobs: - publish: - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') # only allow publishing tagged versions - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 - with: - java-version: 25 - distribution: 'temurin' - cache: 'maven' - - name: Enforce project version ${{ github.event.release.tag_name }} - run: ./mvnw versions:set -B -DnewVersion=${{ github.event.release.tag_name }} - - name: Deploy - run: ./mvnw deploy -B -DskipTests -Psign,deploy-github --no-transfer-progress - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }} - MAVEN_GPG_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} - MAVEN_GPG_KEY_FINGERPRINT: ${{ vars.RELEASES_GPG_KEY_FINGERPRINT }}