Build and Create Pre-Release #19
Workflow file for this run
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: Build and Create Pre-Release | |
on: | |
workflow_dispatch: | |
inputs: | |
addCommit: | |
description: 'Pre-release?' | |
required: false | |
type: boolean | |
sendSlackMessage: | |
description: 'Send Slack Message?' | |
required: false | |
type: boolean | |
message: | |
description: "What changed (for slack message)" | |
required: true | |
jobs: | |
build-and-release: | |
runs-on: macos-13 | |
steps: | |
- name: "Install Homebrew" | |
run: /bin/bash -c "NONINTERACTIVE=1 $(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
- name: "Install Dependencies" | |
run: /usr/local/bin/brew install dpkg rpm upx zip make wget jq | |
- name: "Install golang" | |
run: | | |
wget https://go.dev/dl/go1.21.0.darwin-amd64.pkg | |
sudo installer -store -pkg go1.21.0.darwin-amd64.pkg -target / | |
- name: "Install Packages.pkg for making macos PKG files" | |
run: wget https://docker-laptop.s3.eu-west-1.amazonaws.com/Packages.pkg && sudo installer -pkg Packages.pkg -target / | |
- name: "Git checkout" | |
uses: actions/checkout@v3 | |
- name: "Compile and create linux packages" | |
env: | |
ADDCOMMIT: ${{ inputs.addCommit }} | |
run: | | |
buildcmd="build-prerelease" | |
[ "${ADDCOMMIT}" = "false" ] && buildcmd="build-official" | |
export PATH=$PATH:/usr/local/bin:/usr/local/go/bin | |
cd ~/work/aerolab/aerolab/src && make cleanall && make ${buildcmd} && make pkg-linux | |
- name: "Print aerolab version" | |
run: cd ~/work/aerolab/aerolab/src && ../bin/aerolab-macos-amd64 version | |
- name: "Prepare keychain for signing MacOS" | |
env: | |
keypw: ${{ secrets.APPLEPW }} | |
INSTALLERP12: ${{ secrets.INSTALLERP12 }} | |
APPLICATIONP12: ${{ secrets.APPLICATIONP12 }} | |
run: | | |
set -e | |
security create-keychain -p mysecretpassword build.keychain | |
security default-keychain -s build.keychain | |
security unlock-keychain -p mysecretpassword build.keychain | |
security set-keychain-settings build.keychain | |
security unlock-keychain -p mysecretpassword build.keychain | |
echo "$APPLICATIONP12" | base64 -d > app.p12 | |
echo "$INSTALLERP12" | base64 -d > install.p12 | |
security import app.p12 -k build.keychain -P $keypw -A | |
security import install.p12 -k build.keychain -P $keypw -A | |
security set-key-partition-list -S apple-tool:,apple: -s -k mysecretpassword build.keychain | |
- name: "Sign and build MacOS" | |
env: | |
xaerolab_appleid: ${{ secrets.APPLEUSER }} | |
xaerolab_applepw: ${{ secrets.APPLEPW }} | |
xaerolab_signer: ${{ secrets.APPLESIGNER }} | |
xaerolab_installsigner: ${{ secrets.APPLEINSTALLSIGNER }} | |
xaerolab_teamid: ${{ secrets.APPLETEAMID }} | |
run: | | |
set -e | |
export aerolab_appleid="${xaerolab_appleid}" | |
export aerolab_applepw="${xaerolab_applepw}" | |
export aerolab_signer="${xaerolab_signer}" | |
export aerolab_installsigner="${xaerolab_installsigner}" | |
export aerolab_teamid="${xaerolab_teamid}" | |
export PATH=$PATH:/usr/local/bin:/usr/local/go/bin && cd ~/work/aerolab/aerolab/src && make macos-build-all && make macos-notarize-all | |
- name: "Create a new pre-release" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
ADDCOMMIT: ${{ inputs.addCommit }} | |
run: | | |
set -e | |
echo "${ADDCOMMIT}" | |
cd ~/work/aerolab/aerolab/bin/packages | |
COMMIT=$(git rev-parse --short HEAD) | |
VER=$(cat ../../VERSION.md) | |
BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
TAG=${VER}-${COMMIT} | |
[ "${ADDCOMMIT}" = "false" ] && TAG=${VER} | |
FULLCOMMIT=$(git rev-parse HEAD) | |
gh release create -R github.com/aerospike/aerolab --notes-file ../../RELEASE.md --prerelease --target ${FULLCOMMIT} --title "AeroLab - v${TAG}" ${TAG} aerolab-linux-amd64-7.0.0.deb aerolab-linux-amd64-7.0.0.rpm aerolab-linux-amd64-7.0.0.zip aerolab-linux-arm64-7.0.0.deb aerolab-linux-arm64-7.0.0.rpm aerolab-linux-arm64-7.0.0.zip aerolab-macos-7.0.0.pkg aerolab-macos-amd64-7.0.0.zip aerolab-macos-arm64-7.0.0.zip | |
- name: "Delete previous pre-release" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
set -e | |
COUNT=$(gh release list -R github.com/aerospike/aerolab -L 100 |grep Pre-release |awk '{print $(NF-1)}' |wc -l) | |
if [ $COUNT -lt 2 ] | |
then | |
echo "Found only one pre-release, not removing" | |
exit 0 | |
else | |
PREV=$(gh release list -R github.com/aerospike/aerolab -L 100 |grep Pre-release |awk '{print $(NF-1)}' |tail -1) | |
echo "Removing $PREV" | |
gh release delete $PREV -R github.com/aerospike/aerolab --yes --cleanup-tag | |
fi | |
- name: "Send slack notification" | |
env: | |
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} | |
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }} | |
ADDCOMMIT: ${{ inputs.addCommit }} | |
MESSAGE: ${{ inputs.message }} | |
SENDSLACK: ${{ inputs.sendSlackMessage }} | |
run: | | |
if [ "${SENDSLACK}" = "true" ] | |
then | |
echo "${ADDCOMMIT}" | |
cd ~/work/aerolab/aerolab | |
COMMIT=$(git rev-parse --short HEAD) | |
VER=$(cat VERSION.md) | |
if [ "${ADDCOMMIT}" = "true" ] | |
then | |
TAG=${VER}-${COMMIT} | |
curl -d "text=A new dev build is available at https://github.com/aerospike/aerolab/releases/tag/${TAG} Changes: ${MESSAGE}" -d "channel=${SLACK_CHANNEL}" -H "Authorization: Bearer ${SLACK_TOKEN}" -X POST https://slack.com/api/chat.postMessage || exit 0 | |
else | |
TAG=${VER} | |
curl -d "text=A new pre-release is available at https://github.com/aerospike/aerolab/releases/tag/${TAG} Changes: ${MESSAGE}" -d "channel=${SLACK_CHANNEL}" -H "Authorization: Bearer ${SLACK_TOKEN}" -X POST https://slack.com/api/chat.postMessage || exit 0 | |
fi | |
fi |