Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/actions/compute-artifact-names/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Compute artifact names
description: Central place for computing the artifact names in the CI builds.

inputs:
build-name:
description: The build name (e.g., linux-x86_64, macos-aarch64, etc.)
required: true

runs:
using: composite

steps:
- name: Check valid build name
if: >
! contains(
fromJson('[
"linux-x86_64",
"linux-x86_64-static",
"macos-x86_64",
"macos-aarch64",
"macos-universal"
]'),
inputs.build-name
)
shell: sh
run: |
echo '::error::Invalid build name provided: ${{ inputs.build-name }}.'
exit 1

- name: Set artifact names
id: set-artifact-names
shell: sh
run: |
echo "artifact-name=wasp-cli-${{ inputs.build-name }}" >> $GITHUB_OUTPUT
echo "tarball-name=wasp-${{ inputs.build-name }}.tar.gz" >> $GITHUB_OUTPUT

outputs:
artifact-name:
value: ${{ steps.set-artifact-names.outputs.artifact-name }}
description: "The name of the artifact attached to the CI build."
tarball-name:
value: ${{ steps.set-artifact-names.outputs.tarball-name }}
description: "The name of the tarball inside the artifact."
16 changes: 12 additions & 4 deletions .github/actions/fetch-nightly-cli/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ runs:
using: composite

steps:
- name: Compute artifact names
uses: ./.github/actions/compute-artifact-names
id: compute-artifact-names
with:
build-name: ${{ runner.os == 'Linux' && 'linux' || 'macos' }}-${{ runner.arch == 'ARM64' && 'aarch64' || 'x86_64' }}

- name: Get latest successful run ID
id: get_run_id
shell: bash
Expand Down Expand Up @@ -61,7 +67,9 @@ runs:
GH_TOKEN: ${{ inputs.token }}
RUN_ID: ${{ steps.get_run_id.outputs.run_id }}
OUTPUT_DIR: ${{ inputs.output-dir }}
ARTIFACT_NAME:
# This is the name of the artifact (not the file), which must be in sync with:
# /.github/workflows/ci-waspc-build.yaml
"wasp-cli-${{ runner.os == 'Linux' && 'linux' || 'macos' }}-${{ runner.arch == 'ARM64' && 'aarch64' || 'x86_64' }}"
ARTIFACT_NAME: ${{ steps.compute-artifact-names.outputs.artifact-name }}

outputs:
artifact-path:
description: "The path to the downloaded artifact directory."
value: ${{ inputs.output-dir }}/${{ steps.compute-artifact-names.outputs.artifact-name }}
87 changes: 62 additions & 25 deletions .github/workflows/ci-waspc-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ env:

jobs:
build:
outputs:
output_linux-x86_64: ${{ steps.set-outputs.outputs.output_linux-x86_64 }}
output_linux-x86_64-static: ${{ steps.set-outputs.outputs.output_linux-x86_64-static }}
output_macos-x86_64: ${{ steps.set-outputs.outputs.output_macos-x86_64 }}
output_macos-aarch64: ${{ steps.set-outputs.outputs.output_macos-aarch64 }}

strategy:
fail-fast: false

Expand Down Expand Up @@ -92,6 +98,12 @@ jobs:
steps:
- uses: actions/checkout@v6

- name: Compute artifact names
uses: ./.github/actions/compute-artifact-names
id: compute-artifact-names
with:
build-name: ${{ matrix.env.name }}

- name: Install dependencies
if: ${{ matrix.env.install-deps }}
run: ${{ matrix.env.install-deps }}
Expand All @@ -112,52 +124,77 @@ jobs:
run: |
./run build:all${{ matrix.env.static && ':static' || '' }}
mkdir -p artifacts
./tools/make_binary_package.sh "artifacts/wasp-${{ matrix.env.name }}.tar.gz"
./tools/make_binary_package.sh "artifacts/${{ steps.compute-artifact-names.outputs.tarball-name }}"

- uses: actions/upload-artifact@v4
with:
path: ./waspc/artifacts/*
name:
"wasp-cli-${{ matrix.env.name }}"
# This name must be in sync with the artifact name used in:
# /.github/actions/fetch-nightly-cli/action.yaml
path: ./waspc/artifacts/${{ steps.compute-artifact-names.outputs.tarball-name }}
name: ${{ steps.compute-artifact-names.outputs.artifact-name }}
if-no-files-found: error

- name: Set job outputs
id: set-outputs
env:
OUTPUT_DATA: ${{ toJson(steps.compute-artifact-names.outputs) }}
run: |
{
echo 'output_${{ matrix.env.name }}<<EOF'
echo "$OUTPUT_DATA"
echo 'EOF'
} >> $GITHUB_OUTPUT

build-universal:
name: Build Wasp (universal)
needs: build
runs-on: macos-15

env:
X86_64_TARBALL_NAME: ${{ fromJson(needs.build.outputs.output_macos-x86_64).tarball-name }}
X86_64_ARTIFACT_NAME: ${{ fromJson(needs.build.outputs.output_macos-x86_64).artifact-name }}
AARCH64_TARBALL_NAME: ${{ fromJson(needs.build.outputs.output_macos-aarch64).tarball-name }}
AARCH64_ARTIFACT_NAME: ${{ fromJson(needs.build.outputs.output_macos-aarch64).artifact-name }}

steps:
- name: Download macOS binaries
- uses: actions/checkout@v6

- name: Compute artifact names
uses: ./.github/actions/compute-artifact-names
id: compute-artifact-names
with:
build-name: macos-universal

- name: Download macOS Intel binaries
uses: actions/download-artifact@v5
with:
pattern: wasp-cli-macos-*
name: "${{ env.X86_64_ARTIFACT_NAME }}"

- name: Download macOS ARM binaries
uses: actions/download-artifact@v5
with:
name: "${{ env.AARCH64_ARTIFACT_NAME }}"

- name: Unpack, create universal binary and pack
run: |
set -ex # Fail on error and print each command
set -eux # Fail on error and print each command

input_arch=(
macos-x86_64
macos-aarch64
)
mkdir x86_64 aarch64 universal

# Extract each architecture
for arch in "${input_arch[@]}"; do
mkdir "arch-$arch"
tar -xzf "wasp-cli-${arch}/wasp-${arch}.tar.gz" -C "arch-$arch"
done
# Unpack both architectures
tar -xzf "$X86_64_TARBALL_NAME" -C x86_64
tar -xzf "$AARCH64_TARBALL_NAME" -C aarch64

mkdir universal
# Create the universal binary
lipo -create arch-*/wasp-bin -output universal/wasp-bin
# Copy the data folder too
cp -R "arch-${input_arch[0]}/data" universal/
lipo \
-create "x86_64/wasp-bin" "aarch64/wasp-bin" \
-output "universal/wasp-bin"

# Copy the data folder too (we take the first one, should be identical in both)
cp -R "x86_64/data/" "universal/"

# Pack back up
tar -czf wasp-macos-universal.tar.gz -C universal .
tar -czf ${{ steps.compute-artifact-names.outputs.tarball-name }} -C universal .

- uses: actions/upload-artifact@v4
with:
name: wasp-cli-macos-universal
path: ./wasp-macos-universal.tar.gz
name: ${{ steps.compute-artifact-names.outputs.artifact-name }}
path: ./${{ steps.compute-artifact-names.outputs.tarball-name }}