Skip to content

Commit

Permalink
#3 Added aiSSEMBLE GitHub Action release job
Browse files Browse the repository at this point in the history
  • Loading branch information
aiSSEMBLE Team committed Sep 12, 2024
1 parent 18036ab commit 3138cff
Show file tree
Hide file tree
Showing 3 changed files with 231 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/actions/split_version/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 'Split Version'
description: 'Splits the inputed version into major, minor, and patch components'
inputs:
version:
description: 'Version to split'
required: true
release-branch:
description: 'Release branch'
required: true
existing-version:
description: 'Existing version'
required: true
outputs:
minor-version:
description: "Minor version"
value: ${{ steps.split.outputs.minor-version }}
patch-version:
description: "Patch version"
value: ${{ steps.split.outputs.patch-version }}
is-pre-release:
description: "Is pre-release version"
value: ${{ steps.split.outputs.is-pre-release }}
release-branch:
description: "Is pre-release version"
value: ${{ steps.split.outputs.release-branch }}
existing-version:
description: "Is pre-release version"
value: ${{ steps.split.outputs.existing-version }}

runs:
using: "composite"
steps:
- name: Split
id: split
shell: bash
run: |
major=$(echo ${{ inputs.version }} | cut -d "." -f 1)
minor=$(echo ${{ inputs.version }} | cut -d "." -f 2)
patch=$(echo ${{ inputs.version }} | cut -d "." -f 3 | cut -d "-" -f 1)
minor_version=$major.$minor
patch_version=$major.$minor.$patch
echo "minor-version=$minor_version" >> $GITHUB_OUTPUT
echo "patch-version=$patch_version" >> $GITHUB_OUTPUT
echo "is-pre-release=$( [ "${{ inputs.version }}" != "$patch_version" ] && echo true || echo false)" >> $GITHUB_OUTPUT
echo "release-branch=$( [ "${{ inputs.releaseBranch }}" != "" ] && echo "${{ inputs.releaseBranch }}" || echo "aissemble-release-$minor_version")" >> $GITHUB_OUTPUT
echo "existing-version=$( [ "${{ inputs.existingVersion }}" != "" ] && echo "${{ inputs.existingVersion }}" || echo "$patch_version-SNAPSHOT")" >> $GITHUB_OUTPUT
44 changes: 44 additions & 0 deletions .github/actions/update_antora/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: 'Update Antora docs'
description: 'Updates the Antora docs'
inputs:
version:
description: 'Full version'
required: true
minor-version:
description: 'Minor version'
required: true
patch-version:
description: 'Patch version'
required: true
is-pre-release:
description: 'If the release is a pre-release version'
required: true
release-branch:
description: 'Release branch'
required: true
custom-facet-old-version:
description: 'Version to replace in custom facet schema'
required: true
custom-facet-new-version:
description: 'Version to update in custom facet schema'
required: true

runs:
using: "composite"
steps:
- name: Update
shell: bash
run: |
sed -i "s/^version: .*/version: ${{ inputs.patch-version }}/" docs/antora.yml
version=$( ${{ inputs.is-pre-release }} && echo ${{ inputs.version }} || echo ${{ inputs.minor-version }} )
sed -i "s/^display_version: .*/display_version: $version/" docs/antora.yml
sed -i "s/^prerelease: .*/prerelease: ${{ inputs.is-pre-release }}/" docs/antora.yml
sed -i "s/^ is-pre-release: .*/ is-pre-release: ${{ inputs.is-pre-release }}/" docs/antora.yml
find docs/modules/ROOT/attachments/ -type f -exec sed -i 's|${{ inputs.custom-facet-old-version }}|${{ inputs.custom-facet-new-version }}|g' {} +
git config --global user.email "[email protected]"
git config --global user.name "aiSSEMBLE Team"
git diff
git add .
git commit -S -m "Updating scripts and templates to ${{ inputs.version }}"
git push origin HEAD:${{ inputs.release-branch }}
140 changes: 140 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Release aissemble

on:
workflow_dispatch:
inputs:
releaseVersion:
description: "The version you want to release aiSSEMBLE on."
required: true
type: string
developmentVersion:
description: "The version that dev should be on after this release."
required: true
type: string
releaseBranch:
description: "OPTIONAL: The branch to use for running the release."
required: false
type: string
existingVersion:
description: "OPTIONAL: The existing aiSSEMBLE version. Defaults to patchVersion-SNAPSHOT"
required: false
type: string
dryRun:
description: "OPTIONAL: Used to run the release job as a dry run, skipping the deploy phase"
required: false
default: false
type: boolean

jobs:
build:

runs-on: arc-runner-set-aissemble
env:
DOCKER_CONFIG: /home/runner/.docker
releaseVersion: ${{ inputs.releaseVersion }}
developmentVersion: ${{ inputs.developmentVersion }}
releaseBranch: ${{ inputs.releaseBranch }}
existingVersion: ${{ inputs.existingVersion }}
dryRun: ${{ inputs.dryRun }}

steps:
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PRIVATE_KEY_PASSPHRASE }}
- name: Install required packages
run: |
sudo apt-get update
sudo apt install -y build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl \
git libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev zip unzip \
libpython3.11
- name: Install Python
uses: gabrielfalcao/pyenv-action@v18
with:
default: 3.11.4
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install Helm
run: |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
- name: Install Helm Unittest Plugin
run: |
echo "Updating helm unittest plugin to latest version..."
helm plugin install https://github.com/helm-unittest/helm-unittest.git
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
- name: Create Docker Builder Config File
run: sudo touch /etc/buildkitd.toml
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: actions/checkout@v4
- name: Split version
id: split_version
uses: ./.github/actions/split_version
with:
version: ${{ env.releaseVersion }}
release-branch: ${{ env.releaseBranch }}
existing-version: ${{ env.existingVersion }}
- name: Print release parameters
run: |
echo "Releasing with the following parameters"
echo "Release version: ${{ env.releaseVersion }}"
echo "Development version: ${{ env.developmentVersion }}"
echo "Minor version: ${{ steps.split_version.outputs.minor-version }}"
echo "Patch Version: ${{ steps.split_version.outputs.patch-version }}"
echo "Is pre release version: ${{ steps.split_version.outputs.is-pre-release }}"
echo "Release branch: ${{ steps.split_version.outputs.release-branch }}"
echo "Existing version: ${{ steps.split_version.outputs.existing-version }}"
- name: Checkout release branch
uses: actions/checkout@v4
with:
ref: ${{ steps.split_version.outputs.release-branch }}
- name: Update Antora Docs
uses: ./.github/actions/update_antora
with:
version: ${{ env.releaseVersion }}
minor-version: ${{ steps.split_version.outputs.minor-version }}
patch-version: ${{ steps.split_version.outputs.patch-version }}
is-pre-release: ${{ steps.split_version.outputs.is-pre-release }}
release-branch: ${{ steps.split_version.outputs.release-branch }}
custom-facet-old-version: ${{ steps.split_version.outputs.existing-version }}
custom-facet-new-version: ${{ env.releaseVersion }}
- name: Create settings.xml
run: |
echo "<settings><servers><server><id>ossrh</id><username>${{ secrets.SONATYPE_CENTRAL_REPO_TOKEN_USER }}</username><password>${{ secrets.SONATYPE_CENTRAL_REPO_TOKEN_KEY }}</password></server><server><id>ghcr.io</id><username>${{ secrets.GHCR_IO_USERNAME }}</username><password>${{ secrets.GHCR_IO_TOKEN }}</password></server><server><id>pypi</id><username>${{ secrets.PYPI_USERNAME }}</username><password>${{ secrets.PYPI_TOKEN }}</password></server><server><id>dev-pypi</id><username>${{ secrets.TEST_PYPI_USERNAME }}</username><password>${{ secrets.TEST_PYPI_TOKEN }}</password></server> </servers></settings>" > $HOME/.m2/settings.xml
- name: Release aiSSEMBLE
run: |
./mvnw release:clean release:prepare release:perform -s $HOME/.m2/settings.xml -U -B -Pci,gh-build -DdryRun=${{ env.dryRun }} -DpushChanges=true -DreleaseVersion=${{ env.releaseVersion }} -DdevelopmentVersion=${{ env.developmentVersion }} [email protected] -DsignTag=true -Dmaven.build.cache.enabled=false
- name: Split version
id: split_version_development
uses: ./.github/actions/split_version
with:
version: ${{ env.developmentVersion }}
- name: Update Antora Docs
uses: ./.github/actions/update_antora
with:
version: ${{ env.developmentVersion }}
patch-version: ${{ steps.split_version_development.outputs.patch-version }}
minor-version: ${{ steps.split_version_development.outputs.minor-version }}
is-pre-release: ${{ steps.split_version_development.outputs.is-pre-release }}
release-branch: ${{ steps.split_version.outputs.release-branch }}
custom-facet-old-version: ${{ env.releaseVersion }}
custom-facet-new-version: ${{ env.developmentVersion }}

0 comments on commit 3138cff

Please sign in to comment.