Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 21 additions & 69 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,85 +1,37 @@
# This is a basic workflow to help you get started with Actions
name: Build, Test & Publish

name: Build and Deploy

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ main ]
pull_request:
release:
types: [ created ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 1.8
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
cache: 'maven'

- name: Set up Maven
uses: stCarolas/setup-maven@v4
with:
maven-version: 3.6.3
env:
RELEASE_USERNAME: ${{ github.actor }}
RELEASE_TOKEN: ${{ secrets.PERSONAL_TOKEN }}

- name: Build and Test
run: mvn --batch-mode --update-snapshots clean package
steps:
- uses: actions/checkout@v6

- name: Set settings.xml
uses: s4u/maven-settings-action@v3.1.0
- name: Set up JDK 8
uses: actions/setup-java@v5.2.0
with:
servers: |
[{
"id": "uwdigi-repo-central",
"username": "${{ secrets.MAVEN_REPO_USERNAME }}",
"password": "${{ secrets.MAVEN_REPO_PASSWORD }}"
},
{
"id": "uwdigi-repo-snapshots",
"username": "${{ secrets.MAVEN_REPO_USERNAME }}",
"password": "${{ secrets.MAVEN_REPO_PASSWORD }}"
}]
if: ${{ github.ref == 'refs/heads/main' && github.repository_owner == 'IsantePlus' && github.event_name != 'pull_request' }}

- name: Deploy
run: mvn --batch-mode clean deploy -DskipTests
if: ${{ github.ref == 'refs/heads/main' && github.repository_owner == 'IsantePlus' && github.event_name != 'pull_request'}}


# - uses: s4u/maven-settings-action@v2.2.0
# with:
# servers: |
# [{
# "id": "github-packages",
# "username": "${{ secrets.RELEASE_USERNAME }}",
# "password": "${{ secrets.RELEASE_TOKEN }}"
# }]
# properties: |
# [
# { "maven.wagon.http.ssl.insecure": "true" },
# { "maven.wagon.http.ssl.allowall": "true" },
# { "maven.wagon.http.ssl.ignore.validity.dates": "true"}
# ]
# githubServer: false
# - name: Build with Maven
# run: mvn -P 'github-packages' -B install
# - name: Publish package
# run: mvn -P github-packages -DskipTests -Dfindbugs.skip=true -Dpmd.skip=true -Dcpd.skip=true -B deploy
# env:
# GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
# if: github.event_name == 'release' && github.event.action == 'created'
java-version: '8'
distribution: zulu
cache: maven
server-id: github-packages
server-username: RELEASE_USERNAME
server-password: RELEASE_TOKEN

- name: Build and test
run: mvn -B -P github-packages clean package

- name: Publish package
if: github.event_name == 'release' && github.event.action == 'created'
run: mvn -B -P github-packages -DskipTests -Dfindbugs.skip=true -Dpmd.skip=true -Dcpd.skip=true deploy
67 changes: 67 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: 'Release version'
required: true

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write

env:
RELEASE_USERNAME: ${{ github.actor }}
RELEASE_TOKEN: ${{ secrets.PERSONAL_TOKEN }}

steps:
- uses: actions/checkout@v6

- name: Set up JDK 8
uses: actions/setup-java@v5.2.0
with:
java-version: '8'
distribution: zulu
cache: maven
server-id: github-packages
server-username: RELEASE_USERNAME
server-password: RELEASE_TOKEN

- name: Set release version
run: |
sed -i "s/<revision>.*<\/revision>/<revision>${{ github.event.inputs.version }}<\/revision>/" pom.xml
echo "Set version to ${{ github.event.inputs.version }}"

- name: Build
run: mvn -B -P github-packages -DskipTests -Dfindbugs.skip=true -Dpmd.skip=true -Dcpd.skip=true clean package

- name: Publish to GitHub Packages
run: mvn -B -P github-packages -DskipTests -Dfindbugs.skip=true -Dpmd.skip=true -Dcpd.skip=true deploy

- name: Create release
uses: softprops/action-gh-release@v3.0.0
with:
tag_name: v${{ github.event.inputs.version }}
name: v${{ github.event.inputs.version }}
generate_release_notes: true
files: omod/target/*.omod

- name: Bump to next SNAPSHOT
run: |
IFS='.' read -r major minor patch <<< "${{ github.event.inputs.version }}"
next_patch=$((patch + 1))
next_version="${major}.${minor}.${next_patch}-SNAPSHOT"
sed -i "s/<revision>.*<\/revision>/<revision>${next_version}<\/revision>/" pom.xml
echo "Bumped to ${next_version}"

- name: Commit version bump
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add pom.xml
git commit -m "Bump version to next SNAPSHOT after v${{ github.event.inputs.version }} release"
git push
5 changes: 5 additions & 0 deletions omod/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<!-- Skip default deploy to avoid 409 with deploy-file -->
<id>default-deploy</id>
<phase>none</phase>
</execution>
<execution>
<!-- Deploy OpenMRS omod file -->
<id>deploy-file</id>
Expand Down