Skip to content

Commit

Permalink
Merge pull request #975 from JeremyMcCormick/master
Browse files Browse the repository at this point in the history
Add support for Github Actions plus cleanup and updates to POM files
  • Loading branch information
JeremyMcCormick authored Sep 7, 2023
2 parents 1a8b05e + 5a29086 commit b5a038e
Show file tree
Hide file tree
Showing 36 changed files with 735 additions and 370 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: deploy
on:
workflow_dispatch:
push:
branches:
- master
# Ignore release tags
tags-ignore:
- hps-java-*

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout source code
uses: actions/checkout@v2

- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Deploy Snapshots with Maven
run: mvn -B deploy -s .maven_settings.xml -DretryFailedDeploymentCount=10
env:
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
25 changes: 0 additions & 25 deletions .github/workflows/maven.yml

This file was deleted.

166 changes: 166 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
name: release

permissions: write-all

on:
workflow_dispatch:
inputs:
branch:
description: "Branch to use for release"
required: true
default: "master"
release_version:
description: "Release version"
required: true
default: "auto"
development_version:
description: "New development version"
required: true
default: "auto"
dry_run:
description: "Perform a dry run for testing"
required: false
type: boolean
default: false
skip_tests:
description: "Skip running the tests"
required: false
type: boolean
default: false
skip_javadoc:
description: "Skip javadoc generation"
required: false
type: boolean
default: true
quiet:
description: "Quiet output - only show errors"
required: false
type: boolean
default: false
generate_release_notes:
description: "Generate release notes"
required: false
type: boolean
default: true
deploy_site:
description: "Update the project website"
required: false
type: boolean
default: true
secrets:
SSH_PRIVATE_KEY:
required: true
CI_DEPLOY_USERNAME:
required: true
CI_DEPLOY_PASSWORD:
required: true

jobs:
# TODO: Add test here for a sanity check
release:
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.maven_release_step.outputs.release_tag }}
steps:
- name: Check release version
if: inputs.release_version != 'auto' && inputs.development_version == 'auto'
run: |
echo "ERROR: Release version was provided but next development version was set to auto."
exit 1
- name: Checkout source code
uses: actions/checkout@v2
with:
ref: ${{ inputs.branch }}

- name: Create Maven args file
run: |
touch .maven_args
echo "MAVEN_ARGS_FILE=.maven_args" >> $GITHUB_ENV
- name: Set input release version
if: inputs.release_version != 'auto'
run: |
echo -n "-DreleaseVersion=${{ inputs.release_version }}" >> ${{ env.MAVEN_ARGS_FILE }}
echo "MAVEN_RELEASE_VERSION=${{ inputs.release_version }}" >> $GITHUB_ENV
- name: Set default input release version
if: inputs.release_version == 'auto'
run: echo "MAVEN_RELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed s/-SNAPSHOT//g)" >> $GITHUB_ENV

- name: Set input development version
if: inputs.development_version != 'auto'
run: |
if [[ "${{ inputs.development_version}}" != *-SNAPSHOT ]]
then
echo "ERROR: Development version must end with -SNAPSHOT."
exit 1
fi
echo -n " -DdevelopmentVersion=${{ inputs.development_version }}" >> ${{ env.MAVEN_ARGS_FILE }}
shell: bash

- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Get email
id: get_email
uses: evvanErb/[email protected]
with:
github-username: ${{ github.actor }}

- name: Configure Git user
run: |
git config user.email "${{ steps.get_email.outputs.email }}"
git config user.name "${{ github.actor }}"
echo "Username: ${{ github.actor }}"
echo "Email: ${{ steps.get_email.outputs.email }}"
- name: Set Maven quiet
if: inputs.quiet
run: echo -n " -q" >> ${{ env.MAVEN_ARGS_FILE }}

- name: Set Maven arguments variable
run: |
echo "Extra Maven args: $(cat ${{ env.MAVEN_ARGS_FILE }})"
echo "MAVEN_ARGS=$(cat ${{ env.MAVEN_ARGS_FILE }})" >> $GITHUB_ENV
- name: Perform Maven release
id: maven_release_step
run: |
mvn release:prepare release:perform \
-DdryRun=${{ inputs.dry_run }} \
-DskipTests=${{ inputs.skip_tests }} \
-Darguments="-DskipTests=${{ inputs.skip_tests }} -Dmaven.javadoc.skip=${{ inputs.skip_javadoc }} \
-Dmaven.site.skip=true -Dmaven.site.deploy.skip=true -DgenerateReports=false" \
-B -e -s .maven_settings.xml \
${{ env.MAVEN_ARGS }}
echo "release_tag=${{ github.event.repository.name }}-${{ env.MAVEN_RELEASE_VERSION }}" >> $GITHUB_OUTPUT
env:
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}

- name: Make Github release
id: github_release
if: ${{ !inputs.dry_run }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.repository.name }}-${{ env.MAVEN_RELEASE_VERSION }}
name: ${{ github.event.repository.name }} ${{ env.MAVEN_RELEASE_VERSION }}
generate_release_notes: ${{ inputs.generate_release_notes }}
draft: false
prerelease: false
files: |
./distribution/target/hps-distribution-${{ env.MAVEN_RELEASE_VERSION }}-bin.jar
site:
needs: release
if: ${{ !inputs.dry_run && inputs.deploy_site }}
uses: JeffersonLab/hps-java/.github/workflows/site.yml@master
with:
tag: ${{ needs.release.outputs.release_tag }}
secrets: inherit
63 changes: 63 additions & 0 deletions .github/workflows/site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: site

permissions:
deployments: write
pages: write

on:
workflow_call:
inputs:
tag:
description: "Tag to use for site deployment"
required: true
type: string
workflow_dispatch:
inputs:
tag:
description: "Tag to use for site deployment"
required: true
type: string

jobs:
deploy-site:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3
with:
ref: ${{ inputs.tag }}

- name: Validate tag
run: |
if [ "$(git name-rev --name-only --tags HEAD)" == "undefined" ]; then
echo "ERROR: Reference used as input is not a valid tag."
exit 1
fi
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Get email
id: get_email
uses: evvanErb/[email protected]
with:
github-username: ${{ github.actor }}

- name: Configure Git user
run: |
git config --global user.email "${{ steps.get_email.outputs.email }}"
git config --global user.name "${{ github.actor }}"
echo "Username: ${{ github.actor }}"
echo "Email: ${{ steps.get_email.outputs.email }}"
- name: Build project and run tests
run: mvn clean install verify

- name: Build and deploy the site
run: mvn site site:stage scm-publish:publish-scm -q
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: test

on:
workflow_dispatch:
pull_request:
branches: [master]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Build and run tests
run: |
mvn -B install -T4
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ target/

# editor swap files
.*.swp

# local Maven repository
.m2repo

# ignore user VS Code settings
.vscode
17 changes: 17 additions & 0 deletions .maven_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>lcsim-repo-releases</id>
<username>${env.CI_DEPLOY_USERNAME}</username>
<password>${env.CI_DEPLOY_PASSWORD}</password>
</server>
<server>
<id>lcsim-repo-snapshots</id>
<username>${env.CI_DEPLOY_USERNAME}</username>
<password>${env.CI_DEPLOY_PASSWORD}</password>
</server>
</servers>
</settings>
7 changes: 6 additions & 1 deletion analysis/pom.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>hps-analysis</artifactId>
<name>analysis</name>
<description>common analysis code</description>

<parent>
<groupId>org.hps</groupId>
<artifactId>hps-java</artifactId>
<relativePath>../pom.xml</relativePath>
<version>5.2.1-SNAPSHOT</version>
</parent>

<dependencies>
<dependency>
<groupId>org.hps</groupId>
<artifactId>hps-recon</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand All @@ -29,4 +33,5 @@
</plugin>
</plugins>
</build>
</project>

</project>
Loading

0 comments on commit b5a038e

Please sign in to comment.