Release ESMF SDK #75
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release ESMF SDK | |
on: | |
workflow_dispatch: | |
inputs: | |
release_version: | |
description: 'Version number of the release' | |
required: true | |
jobs: | |
check-preconditions: | |
name: Check preconditions | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Required for Maven | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
overwrite-settings: false | |
- name: Setup Git | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
- name: Sanity check version | |
if: ${{ !contains( github.event.inputs.release_version, '-M' ) }} | |
run: | | |
current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | |
release_version=${{ github.event.inputs.release_version }} | |
if [[ $release_version =~ ^[0-9]+.[0-9]+.[0-9]+$ ]] | |
then | |
echo version is valid | |
else | |
echo release version $release_version is invalid | |
exit 1 | |
fi | |
# The Linux build will upload the local Nexus deployment repository | |
# (i.e., what will be deployed to OSSRH/Maven Central) | |
# and the Linux-specific samm-cli binary to the build artifacts | |
build-linux: | |
name: Linux build | |
needs: [check-preconditions] | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Even though the build itself is done using the GraalVM JDK | |
# (see below), we use the setup-java action to have GPG configured | |
# so that it can be used from the maven-gpg-plugin. | |
- name: Configure GPG | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
gpg-private-key: ${{ secrets.PGP_KEY }} | |
gpg-passphrase: PGP_KEY_PASSWORD | |
overwrite-settings: false | |
- name: Setup JDK | |
uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: '17.0.8' | |
distribution: 'graalvm' | |
components: 'native-image,js' | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
native-image-job-reports: 'true' | |
- name: Cache Maven packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Set Swap Space (Linux) | |
uses: pierotofy/set-swap-space@master | |
with: | |
swap-size-gb: 12 | |
# The Linux build will prepare a local Nexus staging repository | |
# that includes all .jars except the CLI jar | |
- name: Build and run tests | |
run: | | |
export MAVEN_OPTS="-Xmx4096m" | |
# Required for reactor dependencies | |
mvn clean install -DskipTests -Dmaven.javadoc.skip=true | |
mvn versions:set -DnewVersion=${{ github.event.inputs.release_version }} | |
mvn versions:commit | |
# Actual build of core SDK | |
mvn -B -pl '!org.eclipse.esmf:samm-cli' clean deploy -Dmaven.wagon.httpconnectionManager.ttlSeconds=60 -DaltDeploymentRepository=local::default::file://nexus-staging -Psign | |
# Build of CLI | |
pushd tools/samm-cli | |
mvn -B clean verify -Dmaven.wagon.httpconnectionManager.ttlSeconds=60 | |
mvn -B verify -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60 | |
popd | |
# Create .tar.gz of samm-cli | |
pushd tools/samm-cli/target | |
chmod a+x samm | |
tar cfvz samm-cli-linux.tar.gz samm | |
popd | |
mv tools/samm-cli/target/samm-cli-linux.tar.gz . | |
mv tools/samm-cli/target/samm-cli-*.jar . | |
env: | |
PGP_KEY_PASSWORD: ${{ secrets.PGP_KEY_PASSWORD }} | |
- name: Upload staging directory and Linux binary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: linux-artifacts | |
path: | | |
nexus-staging/ | |
samm-cli-linux.tar.gz | |
samm-cli-*.jar | |
# The Windows build will build the Windows-specific samm-cli | |
# and upload the binary to the build artifacts | |
build-windows: | |
name: Windows build | |
needs: [check-preconditions] | |
runs-on: windows-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup JDK | |
uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: '17.0.8' | |
distribution: 'graalvm' | |
components: 'native-image,js' | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
native-image-job-reports: 'true' | |
- name: Cache Maven packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Configure Pagefile (Windows) | |
# Fix for "LINK : fatal error LNK1171: unable to load mspdbcore.dll (error code: 1455)": | |
# This seems to be caused by running out of memory; increasing page file | |
# size suggested here: | |
# https://github.com/actions/virtual-environments/issues/3420#issuecomment-861342418 | |
uses: al-cheb/[email protected] | |
with: | |
minimum-size: 32GB | |
maximum-size: 32GB | |
disk-root: "C:" | |
- name: Build and run tests | |
run: | | |
export MAVEN_OPTS="-Xmx4096m" | |
# Required for reactor dependencies | |
mvn clean install -DskipTests -Dmaven.javadoc.skip=true | |
mvn versions:set -DnewVersion=${{ github.event.inputs.release_version }} | |
mvn versions:commit | |
# Actual build of core SDK | |
mvn -B -pl '!org.eclipse.esmf:samm-cli' clean install -Dmaven.wagon.httpconnectionManager.ttlSeconds=60 | |
# Build of CLI | |
cd tools/samm-cli | |
mvn -B clean verify -Dmaven.wagon.httpconnectionManager.ttlSeconds=60 | |
mvn -B verify -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60 | |
shell: bash | |
- name: Upload Windows binary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: windows-artifacts | |
path: | | |
tools/samm-cli/target/samm.exe | |
tools/samm-cli/target/*.dll | |
tools/samm-cli/target/lib/ | |
release: | |
name: Release | |
needs: [build-linux, build-windows] | |
runs-on: ubuntu-latest | |
steps: | |
# Need to checkout here too, so that we have the pom.xml | |
# with the deployment info available | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Required to have Maven settings.xml set up correctly | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
server-id: ossrh | |
server-username: OSSRH_USERNAME | |
server-password: OSSRH_TOKEN | |
overwrite-settings: false | |
# Required to run the mvn:versions, since enforcer plugin | |
# will check for GraalVM JDK | |
- name: Setup JDK | |
uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: '17.0.8' | |
distribution: 'graalvm' | |
components: 'native-image,js' | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
native-image-job-reports: 'false' | |
- name: Fetch Linux Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: linux-artifacts | |
- name: Fetch Windows Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: windows-artifacts | |
- name: Prepare release | |
run: | | |
# Create Windows CLI zip | |
zip -9 -r samm-cli-windows.zip samm.exe *.dll | |
# Full release: Maven Central | |
# The (apparently) only way to retrieve the staging profile id | |
# is the undocumented rc-list-profiles command of the | |
# nexus-staging-maven-plugin: | |
# mvn org.sonatype.plugins:nexus-staging-maven-plugin:1.6.13:rc-list-profiles -DnexusUrl=https://oss.sonatype.org/ -DserverId=ossrh | |
- name: Release to OSSRH/Maven Central | |
if: ${{ !contains( github.event.inputs.release_version, '-M' ) }} | |
run: | | |
mkdir deploy | |
mv nexus-staging deploy | |
cd deploy | |
mvn org.sonatype.plugins:nexus-staging-maven-plugin:1.6.13:deploy-staged-repository \ | |
-DnexusUrl=https://oss.sonatype.org/ \ | |
-DserverId=ossrh \ | |
-DrepositoryDirectory=nexus-staging \ | |
-DstagingProfileId=7e73217781f2e | |
env: | |
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} | |
# Workaround for https://issues.sonatype.org/browse/OSSRH-66257 | |
# as described in https://stackoverflow.com/a/70157413 | |
MAVEN_OPTS: --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED | |
- name: Set versions | |
continue-on-error: true | |
run: | | |
release_version=${{ github.event.inputs.release_version }} | |
release_branch_name=${release_version%.*}.x | |
echo "release_branch_name=$release_branch_name" >> $GITHUB_ENV | |
# Set version in pom.xml files | |
mvn -B clean install -DskipTests -Dmaven.javadoc.skip=true | |
mvn -B versions:set -DnewVersion=${{ github.event.inputs.release_version }} | |
mvn -B versions:commit | |
# Set version in Antora module | |
yq eval -i '.version = "${{ github.event.inputs.release_version }}"' documentation/developer-guide/antora.yml | |
- name: Commit version changes and push to upstream repository | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
branch: ${{ env.release_branch_name }} | |
commit_user_name: github-actions | |
commit_user_email: [email protected] | |
commit_author: Author <[email protected]> | |
file_pattern: 'documentation/developer-guide/antora.yml pom.xml */pom.xml */*/pom.xml' | |
# Full release: Github | |
- name: "Create Github release (full)" | |
if: ${{ !contains( github.event.inputs.release_version, '-M' ) }} | |
uses: softprops/action-gh-release@v1 | |
id: esmf_sdk_release | |
with: | |
body: "Release version ${{ github.event.inputs.release_version }}." | |
tag_name: v${{ github.event.inputs.release_version }} | |
target_commitish: ${{ env.release_branch_name }} | |
draft: false | |
prerelease: false | |
files: | | |
samm-cli-windows.zip | |
samm-cli-linux.tar.gz | |
samm-cli-*.jar | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Notify issues of release their fix is contained in" | |
if: ${{ !contains( github.event.inputs.release_version, '-M' ) }} | |
uses: apexskier/github-release-commenter@v1 | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
comment-template: | | |
Release {release_link} addresses this. | |
# Milestone release: Write settings to deploy to Github repo | |
- name: Write settings.xml | |
if: contains( github.event.inputs.release_version, '-M' ) | |
uses: DamianReeves/[email protected] | |
with: | |
path: settings.xml | |
contents: | | |
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 | |
https://maven.apache.org/xsd/settings-1.0.0.xsd"> | |
<servers> | |
<server> | |
<id>github</id> | |
<configuration> | |
<httpHeaders> | |
<property> | |
<name>Authorization</name> | |
<value>Bearer ${env.GITHUB_TOKEN}</value> | |
</property> | |
</httpHeaders> | |
</configuration> | |
</server> | |
<server> | |
<id>gpg.passphrase</id> | |
<passphrase>${env.PGP_KEY_PASSWORD}</passphrase> | |
</server> | |
</servers> | |
</settings> | |
write-mode: overwrite | |
# Milestone release: Maven deploy to Github | |
- name: Publish to Github | |
if: contains( github.event.inputs.release_version, '-M' ) | |
run: mvn -s ./settings.xml -B clean -pl '!esmf-sdk-test-report,!documentation,!tools/samm-cli' deploy -DskipTests -Pmilestone-build,sign | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PGP_KEY_PASSWORD: ${{ secrets.PGP_KEY_PASSWORD }} | |
# Milestone release: Github | |
- name: "Create Github release (milestone)" | |
if: contains( github.event.inputs.release_version, '-M' ) | |
uses: softprops/action-gh-release@v1 | |
id: sds_sdk_release | |
with: | |
body: "Release version ${{ github.event.inputs.release_version }}." | |
tag_name: v${{ github.event.inputs.release_version }} | |
target_commitish: ${{ env.release_branch_name }} | |
draft: false | |
prerelease: true | |
files: | | |
samm-cli-windows.zip | |
samm-cli-linux.tar.gz | |
samm-cli-*.jar | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |