Skip to content

Commit

Permalink
Add github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dhadka committed Nov 27, 2023
1 parent ce0dccb commit a7d286c
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 10 deletions.
13 changes: 13 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These are supported funding model platforms

github: dhadka # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI

on:
push:
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java: [ '16', '17', '18', '19', '20' ]
steps:
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: zulu
- run: make
- run: mvn test
90 changes: 90 additions & 0 deletions .github/workflows/stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Validate and stage release

on:
workflow_dispatch:
inputs:
version:
type: string
description: The version to publish
required: true
publish_github:
description: 'Create draft GitHub release'
default: true
type: boolean
publish_maven:
description: 'Create Maven bundle'
default: true
type: boolean
skip_validation:
description: 'Skip version validations'
default: false
type: boolean

jobs:
stage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 16
uses: actions/setup-java@v3
with:
java-version: 16
distribution: temurin
- name: Install required software
run: |
sudo apt install xmlstarlet
- name: Get project settings
run: |
shortname=$(xmlstarlet sel -N x="http://maven.apache.org/POM/4.0.0" -t -v "//x:project/x:artifactId/text()" pom.xml)
version=$(xmlstarlet sel -N x="http://maven.apache.org/POM/4.0.0" -t -v "//x:project/x:version/text()" pom.xml)
echo "BUILD_NAME=${shortname}" >> $GITHUB_ENV
echo "BUILD_VERSION=${version}" >> $GITHUB_ENV
echo "BUILD_ARTIFACT=${shortname}-${version}" >> $GITHUB_ENV
- name: Validate version number
if: ${{ ! inputs.skip_validation }}
run: |
[ "${{ inputs.version }}" == "${BUILD_VERSION}" ] || (>&2 echo "Version does not match value in pom.xml"; exit -1)
[ "${{ inputs.version }}" == "$(cat README.md | grep -m 1 '<version>' | tr -d '<>/[:alpha:][:space:]')" ] || (>&2 echo "Version does not match value in README.md"; exit -1)
- name: Build artifact
run: mvn package javadoc:jar
- name: Sign Maven artifacts and create bundle
if: ${{ inputs.publish_maven }}
run: |
echo -n "${GPG_SIGNING_KEY}" | base64 --decode | gpg --import
mkdir maven
cp pom.xml maven/${BUILD_ARTIFACT}.pom
cp target/${BUILD_ARTIFACT}.jar maven/
cp target/${BUILD_ARTIFACT}-sources.jar maven/
cp target/${BUILD_ARTIFACT}-javadoc.jar maven/
[ -f "target/${BUILD_ARTIFACT}-jar-with-dependencies.jar" ] && cp target/${BUILD_ARTIFACT}-jar-with-dependencies.jar maven/
pushd maven
gpg -ab ${BUILD_ARTIFACT}.pom
gpg -ab ${BUILD_ARTIFACT}.jar
gpg -ab ${BUILD_ARTIFACT}-sources.jar
gpg -ab ${BUILD_ARTIFACT}-javadoc.jar
[ -f "${BUILD_ARTIFACT}-jar-with-dependencies.jar" ] && gpg -ab ${BUILD_ARTIFACT}-jar-with-dependencies.jar
jar -cvf ${BUILD_ARTIFACT}-bundle.jar *
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
- name: Upload Maven bundle
if: ${{ inputs.publish_maven }}
uses: actions/upload-artifact@v3
with:
name: Maven bundle
path: maven/*-bundle.jar
- name: Stage GitHub release
if: ${{ inputs.publish_github }}
run: |
gh release create "v${{ inputs.version }}" --draft --title "Version ${{ inputs.version }}" \
target/${BUILD_ARTIFACT}.jar \
$([ -f "${BUILD_ARTIFACT}-jar-with-dependencies.jar" ] && echo "target/${BUILD_ARTIFACT}-jar-with-dependencies.jar" || echo "")
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload release artifacts
uses: actions/upload-artifact@v3
with:
name: Release artifacts
path: target/*.jar
10 changes: 0 additions & 10 deletions src/main/resources/overview.html

This file was deleted.

0 comments on commit a7d286c

Please sign in to comment.