Merge pull request #491 from posit-dev/upkeep/split-release #406
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 Ark Release" | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
# Extract the current version of ARK from its Cargo.toml file. | |
get_version: | |
name: Determine ARK Version | |
runs-on: ubuntu-latest | |
outputs: | |
ARK_VERSION: ${{ steps.extract_version.outputs.result }} | |
steps: | |
# Checkout sources | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
# Extract version | |
- name: Determine Version | |
id: extract_version | |
run: | | |
VERSION=$(cat crates/ark/Cargo.toml | grep '^version' | sed -e "s/[^.0-9]//g") | |
echo "ARK version: ${VERSION}" | |
echo "result=${VERSION}" >> $GITHUB_OUTPUT | |
# Check to see whether we have already released this version. If we have, we will skip the | |
# release process later on. | |
check_release: | |
name: Check for Existing Release | |
runs-on: ubuntu-latest | |
needs: [get_version] | |
outputs: | |
EXISTING_RELEASE: ${{ steps.release_flag.outputs.result }} | |
steps: | |
- name: Check for existing release tag | |
uses: mukunku/[email protected] | |
id: check_tag | |
with: | |
tag: ${{ needs.get_version.outputs.ARK_VERSION }} | |
- name: Set release flag | |
id: release_flag | |
run: | | |
echo "Existing ${{ needs.get_version.outputs.ARK_VERSION }} release: ${{steps.check_tag.outputs.exists}}" | |
echo "result=${{steps.check_tag.outputs.exists}}" >> $GITHUB_OUTPUT | |
do_release: | |
name: Trigger a new release | |
if: ${{ needs.check_release.outputs.EXISTING_RELEASE == 'false' }} | |
runs-on: ubuntu-latest | |
needs: [check_release] | |
steps: | |
- name: Dummy step | |
run: echo "" | |
# Build ARK for macOS. Both arm64 (Apple Silicon) and x64 (Intel) hosts. | |
build_macos: | |
name: Build macOS | |
uses: ./.github/workflows/release-macos.yml | |
needs: [do_release, get_version] | |
secrets: inherit | |
with: | |
version: ${{ needs.get_version.outputs.ARK_VERSION }} | |
build_windows: | |
name: Build Windows | |
uses: ./.github/workflows/release-windows.yml | |
needs: [do_release, get_version] | |
secrets: inherit | |
with: | |
version: ${{ needs.get_version.outputs.ARK_VERSION }} | |
build_linux: | |
name: "Build Linux" | |
uses: ./.github/workflows/release-linux.yml | |
needs: [do_release, get_version] | |
secrets: inherit | |
with: | |
version: ${{ needs.get_version.outputs.ARK_VERSION }} | |
create_release: | |
name: Create Release | |
runs-on: [self-hosted, macos, arm64] | |
needs: [do_release, get_version, build_macos, build_windows, build_linux] | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
steps: | |
- name: Create release | |
uses: actions/create-release@v1 | |
id: create_release | |
with: | |
draft: false | |
prerelease: true | |
release_name: ${{ needs.get_version.outputs.ARK_VERSION }} | |
tag_name: ${{ needs.get_version.outputs.ARK_VERSION }} | |
# Uploads binaries, if we created a release | |
upload_release_binaries: | |
name: Upload Release Binaries | |
runs-on: [self-hosted, macos, arm64] | |
needs: [create_release, get_version] | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
DEBUG_FLAG: ${{ matrix.flavor == 'debug' && '-debug' || '' }} | |
strategy: | |
max-parallel: 1 | |
matrix: | |
flavor: [debug, release] | |
steps: | |
# Download all binaries | |
- name: Download macOS arm64 kernel (${{ matrix.flavor }}) | |
uses: actions/download-artifact@v4 | |
with: | |
name: ark-${{ matrix.flavor }}-darwin-arm64-archive | |
- name: Download macOS x64 kernel (${{ matrix.flavor}}) | |
uses: actions/download-artifact@v4 | |
with: | |
name: ark-${{ matrix.flavor }}-darwin-x64-archive | |
- name: Download Windows x64 kernel (${{ matrix.flavor}}) | |
uses: actions/download-artifact@v4 | |
with: | |
name: ark-${{ matrix.flavor }}-windows-x64-archive | |
- name: Download Linux x64 kernel (${{ matrix.flavor}}) | |
uses: actions/download-artifact@v4 | |
with: | |
name: ark-${{ matrix.flavor }}-linux-x64-archive | |
# Combine macOS binaries to a single binary with lipo | |
- name: Create macOS universal binary | |
run: | | |
# Decompress x64 builds | |
rm -rf x64 && mkdir x64 && pushd x64 | |
unzip ../ark-${{ needs.get_version.outputs.ARK_VERSION }}-${{ matrix.flavor }}-darwin-x64.zip | |
popd | |
# Decompress arm64 build | |
rm -rf arm64 && mkdir arm64 && pushd arm64 | |
unzip ../ark-${{ needs.get_version.outputs.ARK_VERSION }}-${{ matrix.flavor }}-darwin-arm64.zip | |
popd | |
# Create a universal binary | |
lipo -create x64/ark arm64/ark -output ark | |
# Compress and bundle licenses | |
ARCHIVE="$GITHUB_WORKSPACE/ark-${{ needs.get_version.outputs.ARK_VERSION }}${{ env.DEBUG_FLAG }}-darwin-universal.zip" | |
[ -e LICENSE ] || cp "$GITHUB_WORKSPACE/LICENSE" LICENSE | |
[ -e NOTICE ] || cp "$GITHUB_WORKSPACE/crates/ark/NOTICE" NOTICE | |
zip -Xry $ARCHIVE ark LICENSE NOTICE | |
- name: Upload macOS release artifact (universal) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ needs.create_release.outputs.upload_url }} | |
asset_path: ark-${{ needs.get_version.outputs.ARK_VERSION }}${{ env.DEBUG_FLAG }}-darwin-universal.zip | |
asset_name: ark-${{ needs.get_version.outputs.ARK_VERSION }}${{ env.DEBUG_FLAG }}-darwin-universal.zip | |
asset_content_type: application/octet-stream | |
- name: Upload Windows release artifact (x64) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ needs.create_release.outputs.upload_url }} | |
asset_path: ark-${{ needs.get_version.outputs.ARK_VERSION }}-${{ matrix.flavor }}-windows-x64.zip | |
asset_name: ark-${{ needs.get_version.outputs.ARK_VERSION }}${{ env.DEBUG_FLAG }}-windows-x64.zip | |
asset_content_type: application/octet-stream | |
- name: Upload Linux release artifacts (x64) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ needs.create_release.outputs.upload_url }} | |
asset_path: ark-${{ needs.get_version.outputs.ARK_VERSION }}-${{ matrix.flavor }}-linux-x64.zip | |
asset_name: ark-${{ needs.get_version.outputs.ARK_VERSION }}${{ env.DEBUG_FLAG }}-linux-x64.zip | |
asset_content_type: application/octet-stream | |
status: | |
if: ${{ failure() }} | |
runs-on: self-hosted | |
needs: [build_macos, build_windows, get_version] | |
steps: | |
- name: Notify slack if build fails | |
uses: slackapi/[email protected] | |
id: slack-failure | |
with: | |
payload: | | |
{ | |
"message": "Positron build ${{ needs.get_version.outputs.ARK_VERSION }} failed", | |
"status": "Failure", | |
"run_url": "https://github.com/posit-dev/positron/actions/runs/${{ github.run_id }}" | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |