From 049e46c00a56eec77fdc91ff0597087f146e6c1b Mon Sep 17 00:00:00 2001 From: Edoardo Vacchi Date: Fri, 8 Nov 2024 09:44:11 +0100 Subject: [PATCH] Add CI for PRs and release flow Signed-off-by: Edoardo Vacchi --- .github/workflows/ci.yaml | 30 +++++++++++++ .github/workflows/release.yaml | 78 ++++++++++++++++++++++++++++++++++ .gitignore | 5 +-- 3 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..5773502 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,30 @@ +name: Java CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + java: + name: Java + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + version: [11, 17] + rust: + - stable + steps: + - name: Checkout sources + uses: actions/checkout@v3 + - uses: ./.github/actions/libextism + - name: Set up Java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '${{ matrix.version }}' + - name: Test Java + run: | + mvn --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn verify diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..4a3b5b3 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,78 @@ +name: release + +on: + workflow_dispatch: + inputs: + release-version: + description: 'Version being released' + required: true + branch: + description: 'Branch to release from' + required: true + default: 'main' + +permissions: + contents: write + +jobs: + release: + name: Release + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Java + uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: 'temurin' + server-id: ossrh + server-username: MAVEN_USERNAME + server-password: MAVEN_CENTRAL_TOKEN + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg-passphrase: MAVEN_GPG_PASSPHRASE + + - id: install-secret-key + name: Install gpg secret key + run: | + cat <(echo -e "${{ secrets.GPG_PRIVATE_KEY }}") | gpg --batch --import + gpg --list-secret-keys --keyid-format LONG + + - name: Compile + run: mvn --batch-mode verify + + - name: Setup Git + run: | + git config user.name "Extism BOT" + git config user.email "extism@dylibso.com" + + - name: Set the version + run: | + mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${{ github.event.inputs.release-version }} + ./scripts/update-docs-version ${{ github.event.inputs.release-version }} + git add . + git commit -m "Release version update ${{ github.event.inputs.release-version }}" + git push + git tag ${{ github.event.inputs.release-version }} + git push origin ${{ github.event.inputs.release-version }} + env: + GITHUB_TOKEN: ${{secrets.GH_TOKEN}} + + - name: Release to Maven Central + run: | + mvn --batch-mode clean verify deploy -Drelease -DskipTests=true -X + env: + MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + + - name: Back to Snapshot + run: | + mvn versions:set -DgenerateBackupPoms=false -DnewVersion=999-SNAPSHOT + git add . + git commit -m "Snapshot version update" + git push + env: + GITHUB_TOKEN: ${{secrets.GH_TOKEN}} diff --git a/.gitignore b/.gitignore index 5ff6309..b425f09 100644 --- a/.gitignore +++ b/.gitignore @@ -4,10 +4,7 @@ target/ !**/src/test/**/target/ ### IntelliJ IDEA ### -.idea/modules.xml -.idea/jarRepositories.xml -.idea/compiler.xml -.idea/libraries/ +.idea/ *.iws *.iml *.ipr