Skip to content

Commit

Permalink
Add CI for PRs and release flow
Browse files Browse the repository at this point in the history
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
  • Loading branch information
evacchi committed Nov 8, 2024
1 parent 2572335 commit 049e46c
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 4 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -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
78 changes: 78 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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}}
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 049e46c

Please sign in to comment.