diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 43ec732..782498e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ on: pull_request: branches: - main + workflow_dispatch: permissions: contents: read @@ -28,3 +29,44 @@ jobs: - name: Build and test run: mvn --batch-mode clean verify + + gpg-signing: + if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main') + runs-on: ubuntu-latest + + env: + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} + + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Set up Java + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: '21' + cache: maven + + - name: Import GPG key + env: + MAVEN_GPG_PRIVATE_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} + run: | + printf '%s\n' "$MAVEN_GPG_PRIVATE_KEY" | gpg --batch --import + + - name: Sign artifacts + run: mvn --batch-mode clean verify -Pgpg-signing + + - name: Verify signatures + run: | + gpg --verify micro-env/target/micro-env-0.1.0-SNAPSHOT.jar.asc \ + micro-env/target/micro-env-0.1.0-SNAPSHOT.jar + + gpg --verify micro-env/target/micro-env-0.1.0-SNAPSHOT-sources.jar.asc \ + micro-env/target/micro-env-0.1.0-SNAPSHOT-sources.jar + + gpg --verify micro-env/target/micro-env-0.1.0-SNAPSHOT-javadoc.jar.asc \ + micro-env/target/micro-env-0.1.0-SNAPSHOT-javadoc.jar + + gpg --verify micro-env/target/micro-env-0.1.0-SNAPSHOT.pom.asc \ + micro-env/target/micro-env-0.1.0-SNAPSHOT.pom \ No newline at end of file