Build #59
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 | |
on: | |
schedule: | |
# Run nightly at 00:00 | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
inputs: | |
otp-ref-name: | |
required: true | |
otp-ref: | |
required: true | |
openssl-version: | |
default: "3.1.6" | |
wxwidgets-version: | |
default: "3.2.6" | |
jobs: | |
schedule: | |
name: "Schedule nightly" | |
if: github.event_name == 'schedule' | |
runs-on: ubuntu-latest | |
permissions: | |
actions: write | |
steps: | |
- name: "Schedule nightly" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
ref=$(gh api repos/erlang/otp/commits/master --jq .sha) | |
gh workflow run --repo "${GITHUB_REPOSITORY}" build.yml --field otp-ref-name=master --field otp-ref=$ref | |
ref=$(gh api repos/erlang/otp/commits/maint --jq .sha) | |
gh workflow run --repo "${GITHUB_REPOSITORY}" build.yml --field otp-ref-name=maint --field otp-ref=$ref | |
build_macos: | |
name: "Build ${{ inputs.otp-ref-name }}-macos-${{ matrix.pair.arch }}" | |
if: github.event_name == 'workflow_dispatch' | |
runs-on: ${{ matrix.pair.os }} | |
permissions: | |
actions: write | |
contents: write | |
env: | |
OTP_REF_NAME: ${{ inputs.otp-ref-name }} | |
OPENSSL_VERSION: ${{ inputs.openssl-version }} | |
OPENSSL_DIR: /tmp/builds/openssl-${{ inputs.openssl-version }}-macos-${{ matrix.pair.arch }} | |
WXWIDGETS_VERSION: ${{ inputs.wxwidgets-version }} | |
WXWIDGETS_DIR: /tmp/builds/wxwidgets-${{ inputs.wxwidgets-version }}-macos-${{ matrix.pair.arch }} | |
OTP_DIR: /tmp/builds/otp-${{ inputs.otp-ref-name }}-${{ inputs.otp-ref }}-openssl-${{ inputs.openssl-version }}-wxwidgets-${{ inputs.wxwidgets-version }}-macos-${{ matrix.pair.arch }} | |
OTP_REF: ${{ inputs.otp-ref }} | |
strategy: | |
matrix: | |
include: | |
- pair: | |
os: macos-13 | |
arch: amd64 | |
- pair: | |
os: macos-14 | |
arch: arm64 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: ${{ env.OPENSSL_DIR }} | |
key: openssl-${{ env.OPENSSL_VERSION }}-macos-${{ matrix.pair.arch }} | |
- uses: actions/cache@v4 | |
with: | |
path: ${{ env.WXWIDGETS_DIR }} | |
key: wxwidgets-${{ env.WXWIDGETS_VERSION }}-macos-${{ matrix.pair.arch }} | |
# Uncomment when testing | |
- uses: actions/cache@v4 | |
id: otp-cache | |
with: | |
path: ${{ env.OTP_DIR }} | |
key: otp-${{ env.OTP_REF }}-openssl-${{ env.OPENSSL_VERSION }}-wxwidgets-${{ env.WXWIDGETS_VERSION }}-macos-${{ matrix.pair.arch }} | |
- name: "Build OTP" | |
# Uncomment `if` when testing | |
if: steps.otp-cache.outputs.cache-hit != 'true' | |
run: | | |
bash scripts/build_otp_macos.bash "${{ env.OTP_REF_NAME }}" | |
# - name: Set up Git credentials | |
# env: | |
# # This is a personal access token for user wojtekmach-erlef-bot that has write access. | |
# # We need a token with `workflows` permissions because by pushing git tags | |
# # (from upstream, erlang/otp) we're modifying workflow files (.github/workflows) | |
# # on those tags and that is restricted. Perhaps this would be not necessary if this repo | |
# # was a _fork_ of erlang/otp. | |
# GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} | |
# run: | | |
# git config --global credential.helper store | |
# echo "https://x-access-token:${GITHUB_TOKEN}@github.com" > ~/.git-credentials | |
- name: "Upload" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
if [[ "${OTP_REF_NAME}" == master ]] || [[ "${OTP_REF_NAME}" == maint* ]]; then | |
ref_name="${OTP_REF_NAME}-latest" | |
else | |
ref_name="${OTP_REF_NAME}" | |
fi | |
# TODO: | |
# git remote add upstream https://github.com/erlang/otp | |
# git fetch upstream | |
# git tag $ref_name $OTP_REF --force | |
# git push origin $ref_name --force | |
if ! gh release view $ref_name; then | |
if ! echo "$REF_NAME" | grep -qE 'tc|maint|master'; then | |
if [ -f builds/macos-arm64.txt]; then | |
latest_version=`cat builds/macos-arm64.txt | grep OTP- | grep -v rc | sed s/OTP-//g | sort --reverse -V | head -1` | |
version=$(echo "$ref_name" | sed 's/^OTP-//') | |
if [ "$(printf '%s\n' "$latest_version" "$version" | sort -V | head -1)" != "$latest_version" ]; then | |
latest=true | |
else | |
latest=false | |
fi | |
else | |
latest=false | |
fi | |
else | |
latest=false | |
fi | |
# Initial commit | |
target=b5893a3c3a8d0ab54be5d04de450b24d9e5aa149 | |
gh release create \ | |
--repo ${{ github.repository }} \ | |
--title $ref_name \ | |
--notes "Automated build for https://github.com/erlang/otp/tree/${OTP_REF_NAME}" \ | |
--target $target \ | |
--latest $latest \ | |
$ref_name | |
fi | |
tgz="$OTP_REF_NAME-macos-${{ matrix.pair.arch }}.tar.gz" | |
tar czf $tgz --cd $OTP_DIR . | |
gh release upload \ | |
--repo ${{ github.repository }} \ | |
--clobber \ | |
$ref_name \ | |
$tgz | |
gh workflow run update_builds_txt.yaml \ | |
--repo "${GITHUB_REPOSITORY}" \ | |
--ref "${GITHUB_REF}" \ | |
--field otp-ref-name="${OTP_REF_NAME}" \ | |
--field otp-ref="${OTP_REF}" \ | |
--field arch=${{ matrix.pair.arch }} |