diff --git a/.github/actions/split_version/action.yaml b/.github/actions/split_version/action.yaml new file mode 100644 index 000000000..8695005c1 --- /dev/null +++ b/.github/actions/split_version/action.yaml @@ -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 + diff --git a/.github/actions/update_antora/action.yaml b/.github/actions/update_antora/action.yaml new file mode 100644 index 000000000..d4c0d90b6 --- /dev/null +++ b/.github/actions/update_antora/action.yaml @@ -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 "aissemble@bah.com" + 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 }} + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..c1808390e --- /dev/null +++ b/.github/workflows/release.yml @@ -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 "ossrh${{ secrets.SONATYPE_CENTRAL_REPO_TOKEN_USER }}${{ secrets.SONATYPE_CENTRAL_REPO_TOKEN_KEY }}ghcr.io${{ secrets.GHCR_IO_USERNAME }}${{ secrets.GHCR_IO_TOKEN }}pypi${{ secrets.PYPI_USERNAME }}${{ secrets.PYPI_TOKEN }}dev-pypi${{ secrets.TEST_PYPI_USERNAME }}${{ secrets.TEST_PYPI_TOKEN }} " > $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 }} -Dgpg.keyname=aissemble@bah.com -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 }} +