Create Tagged Release #60
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: "Create Tagged Release" | |
on: | |
workflow_dispatch: | |
inputs: | |
release_version: | |
description: 'Version number of the release' | |
required: true | |
jobs: | |
gh_tagged_release: | |
name: Create tagged release | |
runs-on: ${{ matrix.os }} | |
strategy: | |
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: Cache node modules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Setup NodeJs | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
cache: 'npm' | |
cache-dependency-path: '**/package-lock.json' | |
- 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: Get glibc version | |
if: matrix.os == 'ubuntu-20.04' | |
run: | | |
version=$(ldd --version | head -n 1 | awk '{print $NF}') | |
echo "GLIBC_VERSION=$version" >> $GITHUB_ENV | |
echo "::set-output name=glibc_version::$version" | |
- name: Set antora version | |
if: matrix.os == 'ubuntu-20.04' | |
run: yq eval -i '.version = "${{ github.event.inputs.release_version }}"' documentation/ame-guide/antora.yml | |
- name: Commit version changes and push to upstream repository | |
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 add documentation/ame-guide/antora.yml | |
git commit -m "Set version to ${{ github.event.inputs.release_version }}" | |
git push origin ${{ env.release_branch_name }} | |
git tag v${{ github.event.inputs.release_version }} | |
git push origin v${{ github.event.inputs.release_version }} | |
- name: Download aspect model service into project (Mac) | |
if: matrix.os == 'macos-12' | |
run: | | |
mkdir backend | |
ASSET_ONE_URL=$(curl -sl --header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor-backend/releases/tags/v${{ github.event.inputs.release_version }} | jq '.assets[0].browser_download_url') | |
ASSET_TWO_URL=$(curl -sl --header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor-backend/releases/tags/v${{ github.event.inputs.release_version }} | jq '.assets[1].browser_download_url') | |
ASSET_THREE_URL=$(curl -sl --header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor-backend/releases/tags/v${{ github.event.inputs.release_version }} | jq '.assets[2].browser_download_url') | |
if [[ ${ASSET_ONE_URL} == *"-mac"* ]]; | |
then | |
echo $ASSET_ONE_URL | |
DOWNLOAD_URL=$(curl -sl --header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor-backend/releases/tags/v${{ github.event.inputs.release_version }} | jq -r '.assets[0].url') | |
fi | |
if [[ ${ASSET_TWO_URL} == *"-mac"* ]]; | |
then | |
echo $ASSET_TWO_URL | |
DOWNLOAD_URL=$(curl -sl --header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor-backend/releases/tags/v${{ github.event.inputs.release_version }} | jq -r '.assets[1].url') | |
fi | |
if [[ ${ASSET_THREE_URL} == *"-mac"* ]]; | |
then | |
echo ASSET_THREE_URL | |
DOWNLOAD_URL=$(curl -sl --header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor-backend/releases/tags/v${{ github.event.inputs.release_version }} | jq -r '.assets[2].url') | |
fi | |
curl -L -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/octet-stream" $DOWNLOAD_URL > backend/ame-backend-${{ github.event.inputs.release_version }}-mac | |
chmod 755 backend/ame-backend-${{ github.event.inputs.release_version }}-mac | |
- name: Download aspect model service into project (Linux) | |
if: matrix.os == 'ubuntu-20.04' | |
run: | | |
mkdir backend | |
ASSET_ONE_URL=$(curl -sl --header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor-backend/releases/tags/v${{ github.event.inputs.release_version }} | jq '.assets[0].browser_download_url') | |
ASSET_TWO_URL=$(curl -sl --header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor-backend/releases/tags/v${{ github.event.inputs.release_version }} | jq '.assets[1].browser_download_url') | |
ASSET_THREE_URL=$(curl -sl --header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor-backend/releases/tags/v${{ github.event.inputs.release_version }} | jq '.assets[2].browser_download_url') | |
if [[ ${ASSET_ONE_URL} == *"-linux"* ]]; | |
then | |
echo $ASSET_ONE_URL | |
DOWNLOAD_URL=$(curl -sl --header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor-backend/releases/tags/v${{ github.event.inputs.release_version }} | jq -r '.assets[0].url') | |
fi | |
if [[ ${ASSET_TWO_URL} == *"-linux"* ]]; | |
then | |
echo $ASSET_TWO_URL | |
DOWNLOAD_URL=$(curl -sl --header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor-backend/releases/tags/v${{ github.event.inputs.release_version }} | jq -r '.assets[1].url') | |
fi | |
if [[ ${ASSET_THREE_URL} == *"-linux"* ]]; | |
then | |
echo ASSET_THREE_URL | |
DOWNLOAD_URL=$(curl -sl --header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor-backend/releases/tags/v${{ github.event.inputs.release_version }} | jq -r '.assets[2].url') | |
fi | |
curl -L -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/octet-stream" $DOWNLOAD_URL > backend/ame-backend-${{ github.event.inputs.release_version }}-linux | |
chmod 755 backend/ame-backend-${{ github.event.inputs.release_version }}-linux | |
- name: Download aspect model service into project (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
mkdir backend | |
$RESPONSE=$(curl.exe -sl --header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor-backend/releases/tags/v${{ github.event.inputs.release_version }}") | |
$RESPONSE_JSON=($RESPONSE | ConvertFrom-Json) | |
$url = $null | |
foreach ($asset in $RESPONSE_JSON.assets) { | |
if ($asset.browser_download_url -match ".zip") { | |
$url = $asset.browser_download_url | |
break | |
} | |
} | |
if ($url -ne $null) { | |
echo "Downloading: $url" | |
curl.exe -sL -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/octet-stream" $url -o backend/ame-backend.zip | |
# Unzip the file into the backend directory | |
Expand-Archive -Path backend/ame-backend.zip -DestinationPath backend | |
# Remove the zip file | |
Remove-Item -Path backend/ame-backend.zip | |
} else { | |
Write-Error "No zip file found." | |
} | |
shell: pwsh | |
- name: Install node modules | |
run: npm install | |
working-directory: core | |
- name: Set app version (Unix) | |
if: matrix.os == 'macos-12' || matrix.os == 'ubuntu-20.04' | |
run: npm version ${{ github.event.inputs.release_version }} | |
working-directory: core | |
- name: Set app version (Windows) | |
if: matrix.os == 'windows-latest' | |
run: npm version ${{ github.event.inputs.release_version }} | |
working-directory: core | |
- name: Build electron app (Mac) | |
if: matrix.os == 'macos-12' | |
run: npm run build:mac:prod | |
working-directory: core | |
- name: Build electron app (Linux) | |
if: matrix.os == 'ubuntu-20.04' | |
run: | | |
npm run build:linux:prod | |
mv electron/aspect-model-editor-v${{ github.event.inputs.release_version }}-linux.tar.gz electron/aspect-model-editor-v${{ github.event.inputs.release_version }}-linux-glibc-v${{ env.GLIBC_VERSION }}.tar.gz | |
working-directory: core | |
- name: Build electron app (Windows) | |
if: matrix.os == 'windows-latest' | |
run: npm run build:win:prod | |
working-directory: core | |
- name: Create Windows installer | |
if: matrix.os == 'windows-latest' | |
uses: joncloud/[email protected] | |
with: | |
script-file: win-installer/installer.nsi | |
arguments: "-V3 -DVERSION=${{ github.event.inputs.release_version }}" | |
- name: Upload binary (Windows) | |
if: matrix.os == 'windows-latest' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: aspect-model-editor-v${{ github.event.inputs.release_version }}-win | |
path: win-installer/aspect-model-editor-v${{ github.event.inputs.release_version }}-win.exe | |
# Sign Windows executable | |
- name: Get Artifact ID (Windows) | |
if: matrix.os == 'windows-latest' | |
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 artifact with a name that contains "windows" | |
artifact_id=$(echo "$response" | jq -r '.artifacts[] | select(.name | contains("win")) | .id') | |
# Save the artifact ID in an environment variable | |
echo "ARTIFACT_ID=$artifact_id" >> $GITHUB_ENV | |
env: | |
TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Commit Artifact url and version changes and push to pre release branch for jenkins (Windows) | |
if: matrix.os == 'windows-latest' | |
shell: bash | |
run: | | |
ARTIFACT_URL_WIN="https://api.github.com/repos/eclipse-esmf/esmf-aspect-model-editor/actions/artifacts/$ARTIFACT_ID/zip" | |
BRANCH_NAME="pre_release_configuration" | |
echo "artifact_url_win=$ARTIFACT_URL_WIN" > 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 and version" | |
git push origin $BRANCH_NAME | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Trigger Jenkins Job, for signing executable | |
if: matrix.os == 'windows-latest' | |
shell: bash | |
run: | | |
DATA='{"repository": {"url": "https://github.com/eclipse-esmf/esmf-aspect-model-editor", "html_url": "https://github.com/eclipse-esmf/esmf-aspect-model-editor", "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}" | |
# Release Mac and Linux executables | |
- name: Create GitHub release (Mac) | |
if: ${{ (matrix.os == 'macos-12') && (!contains( github.ref, '-rc' )) }} | |
uses: svenstaro/upload-release-action@latest | |
with: | |
overwrite: true | |
prerelease: false | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: core/electron/aspect-model-editor-v${{ github.event.inputs.release_version }}-mac.dmg | |
tag: v${{ github.event.inputs.release_version }} | |
- name: Create GitHub pre-release (Mac) | |
if: ${{ (matrix.os == 'macos-12') && (contains( github.ref, '-rc' )) }} | |
uses: svenstaro/upload-release-action@latest | |
with: | |
overwrite: true | |
prerelease: true | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: core/electron/aspect-model-editor-v${{ github.event.inputs.release_version }}-mac.dmg | |
tag: v${{ github.event.inputs.release_version }} | |
- name: Create GitHub release (Linux) | |
if: ${{ (matrix.os == 'ubuntu-20.04') && (!contains( github.ref, '-rc' )) }} | |
uses: svenstaro/upload-release-action@latest | |
with: | |
overwrite: true | |
prerelease: false | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: core/electron/aspect-model-editor-v${{ github.event.inputs.release_version }}-linux-glibc-v${{ env.GLIBC_VERSION }}.tar.gz | |
tag: v${{ github.event.inputs.release_version }} | |
- name: Create GitHub pre-release (Linux) | |
if: ${{ (matrix.os == 'ubuntu-20.04') && (contains( github.ref, '-rc' )) }} | |
uses: svenstaro/upload-release-action@latest | |
with: | |
overwrite: true | |
prerelease: true | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: core/electron/aspect-model-editor-v${{ github.event.inputs.release_version }}-linux-glibc-v${{ env.GLIBC_VERSION }}.tar.gz | |
tag: v${{ github.event.inputs.release_version }} |