Skip to content

Create Tagged Release #67

Create Tagged Release

Create Tagged Release #67

name: "Create Tagged Release"
on:
workflow_dispatch:
inputs:
release_version:
description: 'Version number of the release'
required: true
jobs:
build:
name: Create tagged release
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ macos-12, windows-latest, ubuntu-20.04 ]
steps:
- name: Checkout project
uses: actions/checkout@v3
- name: Setup Git
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Configure Pagefile
if: matrix.os == 'windows-latest'
# 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: 16GB
maximum-size: 16GB
disk-root: "C:"
- name: Setup graalvm ce
uses: graalvm/setup-graalvm@v1
with:
version: '22.3.1'
java-version: '17'
components: 'native-image,js'
github-token: ${{ secrets.GITHUB_TOKEN }}
- 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 versions
if: matrix.os == 'ubuntu-20.04'
run: |
release_version=${{ github.event.inputs.release_version }}
release_branch_name=${release_version%.*}.x
echo "release_branch_name=$release_branch_name" >> $GITHUB_ENV
- name: Create Release branch
if: matrix.os == 'ubuntu-20.04'
run: |
git config --global user.email "[email protected]"
git config --global user.name "github-actions"
git checkout -b ${{ env.release_branch_name }}
git push origin ${{ env.release_branch_name }}
- name: Set maven version
if: matrix.os == 'macos-12' || matrix.os == 'ubuntu-20.04'
run: mvn versions:set -DnewVersion=${{ github.event.inputs.release_version }}
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set maven version on Windows
if: matrix.os == 'windows-latest'
run: mvn versions:set -DnewVersion="${{ github.event.inputs.release_version }}"
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Creating native image (Mac)
if: matrix.os == 'macos-12'
run: mvn install -P native-image -DskipTests -Dos.platform=mac -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Creating native image (Linux)
if: matrix.os == 'ubuntu-20.04'
run: mvn install -P native-image -DskipTests -Dos.platform=linux -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up MSVC
if: matrix.os == 'windows-latest'
uses: ilammy/msvc-dev-cmd@v1
- name: Creating native image (Win)
if: matrix.os == 'windows-latest'
run: mvn install -P native-image -DskipTests -D os.platform=win -D maven.wagon.httpconnectionManager.ttlSeconds=60
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Zip File with specified windows awt library
if: matrix.os == 'windows-latest'
run: |
$sourceFolder = "aspect-model-editor-runtime/target"
$zipFile = "aspect-model-editor-v${{ github.event.inputs.release_version }}-win.zip"
$tempDir = New-Item -ItemType Directory -Force -Path "$Env:TEMP\zip_temp"
Get-ChildItem "$sourceFolder" -Filter "*.exe" | Copy-Item -Destination $tempDir
Get-ChildItem "$sourceFolder" -Filter "*.dll" | Copy-Item -Destination $tempDir
Compress-Archive -Path $tempDir\* -DestinationPath $zipFile
Remove-Item -Recurse -Force $tempDir
shell: pwsh
- name: Upload binary (Windows)
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: ame-backend-v${{ github.event.inputs.release_version }}-win
path: |
aspect-model-editor-runtime/target/ame-backend-${{ github.event.inputs.release_version }}-win.exe
aspect-model-editor-runtime/target/*.dll
aspect-model-editor-runtime/target/*.bat
aspect-model-editor-runtime/target/lib/
- name: Upload binary (Mac)
if: matrix.os == 'macos-12'
uses: actions/upload-artifact@v4
with:
name: ame-backend-v${{ github.event.inputs.release_version }}-mac
path: aspect-model-editor-runtime/target/ame-backend-${{ github.event.inputs.release_version }}-mac
- name: Upload binary (Linux)
if: matrix.os == 'ubuntu-20.04'
uses: actions/upload-artifact@v4
with:
name: ame-backend-v${{ github.event.inputs.release_version }}-linux
path: aspect-model-editor-runtime/target/ame-backend-${{ github.event.inputs.release_version }}-linux
# Release Linux executables
- name: Create GitHub release (Linux)
if: ${{ (matrix.os == 'ubuntu-20.04') && (!contains( github.ref, '-M' )) }}
uses: svenstaro/upload-release-action@latest
with:
file_glob: true
overwrite: true
prerelease: false
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: aspect-model-editor-runtime/target/ame-backend-${{ github.event.inputs.release_version }}-linux
tag: v${{ github.event.inputs.release_version }}
- name: Create GitHub pre-release (Linux)
if: ${{ (matrix.os == 'ubuntu-20.04') && (contains( github.ref, '-M' )) }}
uses: svenstaro/upload-release-action@latest
with:
file_glob: true
overwrite: true
prerelease: true
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: aspect-model-editor-runtime/target/ame-backend-${{ github.event.inputs.release_version }}-linux
tag: v${{ github.event.inputs.release_version }}
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v3
# Sign (Windows & Mac) executable
- name: Get Artifact ID (Windows & Mac)
shell: bash
run: |
# Get the list of artifacts for the specified workflow run
response=$(curl -H "Authorization: Bearer $TOKEN" -H "Accept: application/vnd.github+json" "https://api.github.com/repos/${{ github.repository_owner }}/$(echo '${{ github.repository }}' | cut -d'/' -f2)/actions/runs/${{ github.run_id }}/artifacts")
# Filter out the ID of the artifacts
artifact_id_win=$(echo "$response" | jq -r '.artifacts[] | select(.name | contains("win")) | .id')
artifact_id_mac=$(echo "$response" | jq -r '.artifacts[] | select(.name | contains("mac")) | .id')
# Save the artifact ID in an environment variable
echo "ARTIFACT_ID_WIN=$artifact_id_win" >> $GITHUB_ENV
echo "ARTIFACT_ID_MAC=$artifact_id_mac" >> $GITHUB_ENV
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit Artifact url and version changes and push to pre release branch for jenkins (Windows & Mac)
shell: bash
run: |
ARTIFACT_URL_WIN="https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor-backend/actions/artifacts/$ARTIFACT_ID_WIN/zip"
ARTIFACT_URL_MAC="https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor-backend/actions/artifacts/$ARTIFACT_ID_MAC/zip"
BRANCH_NAME="pre_release_configuration"
echo "artifact_url_win=$ARTIFACT_URL_WIN" > parameters.txt
echo "artifact_url_mac=$ARTIFACT_URL_MAC" >> parameters.txt
echo "version=${{ github.event.inputs.release_version }}" >> parameters.txt
git config --global user.email "[email protected]"
git config --global user.name "github-actions"
git checkout -b $BRANCH_NAME
git add parameters.txt
git commit -m "Add parameters.txt with artifact_url_win, artifact_url_mac and version"
git push origin $BRANCH_NAME
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Trigger Jenkins Job, for signing executable
shell: bash
run: |
DATA='{"repository": {"url": "https://github.com/eclipse-esmf/esmf-aspect-model-editor-backend", "html_url": "https://github.com/eclipse-esmf/esmf-aspect-model-editor-backend", "owner": { "name": "ESMF"}}, "pusher": { "name": "GitHub Action", "email": "[email protected]"}}'
SHA1="$(echo -n "${DATA}" | openssl dgst -sha1 -hmac "${WEBHOOK_SECRET}" | sed 's/SHA1(stdin)= //')"
curl -X POST https://ci.eclipse.org/esmf/github-webhook/ -H "Content-Type: application/json" -H "X-GitHub-Event: push" -H "X-Hub-Signature: sha1=${SHA1}" -d "${DATA}"