Skip to content

Commit be4e42f

Browse files
committed
Separate things
1 parent 2a02d48 commit be4e42f

File tree

4 files changed

+163
-23
lines changed

4 files changed

+163
-23
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Compute artifact names
2+
description: Central place for computing the artifact names in the CI builds.
3+
4+
inputs:
5+
build-name:
6+
description: The build name (e.g., linux-x86_64, macos-aarch64, etc.)
7+
required: true
8+
9+
runs:
10+
using: composite
11+
12+
steps:
13+
- name: Check valid build name
14+
if: >
15+
! contains(
16+
fromJson('[
17+
"linux-x86_64",
18+
"linux-x86_64-static",
19+
"macos-x86_64",
20+
"macos-aarch64",
21+
"macos-universal"
22+
]'),
23+
inputs.build-name
24+
)
25+
shell: sh
26+
run: |
27+
# Using the ::error:: prefix lets GitHub handle it as a special string, and shows up as a red error in the logs.
28+
# https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#setting-an-error-message
29+
echo '::error::Invalid build name provided: ${{ inputs.build-name }}.'
30+
exit 1
31+
32+
- name: Set artifact names
33+
id: set-artifact-names
34+
shell: sh
35+
run: |
36+
echo "artifact-name=wasp-cli-${{ inputs.build-name }}" >> $GITHUB_OUTPUT
37+
echo "tarball-name=wasp-${{ inputs.build-name }}.tar.gz" >> $GITHUB_OUTPUT
38+
39+
outputs:
40+
artifact-name:
41+
value: ${{ steps.set-artifact-names.outputs.artifact-name }}
42+
description: "The name of the artifact attached to the CI build."
43+
tarball-name:
44+
value: ${{ steps.set-artifact-names.outputs.tarball-name }}
45+
description: "The name of the tarball inside the artifact."

.github/actions/fetch-nightly-cli/action.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ runs:
1919
using: composite
2020

2121
steps:
22+
- uses: ./.github/actions/compute-artifact-names
23+
id: compute-artifact-names
24+
with:
25+
build-name: ${{ runner.os == 'Linux' && 'linux' || 'macos' }}-${{ runner.arch == 'ARM64' && 'aarch64' || 'x86_64' }}
26+
2227
- name: Get latest successful run ID
2328
id: get_run_id
2429
shell: bash
@@ -61,7 +66,9 @@ runs:
6166
GH_TOKEN: ${{ inputs.token }}
6267
RUN_ID: ${{ steps.get_run_id.outputs.run_id }}
6368
OUTPUT_DIR: ${{ inputs.output-dir }}
64-
ARTIFACT_NAME:
65-
# This is the name of the artifact (not the file), which must be in sync with:
66-
# /.github/workflows/ci-waspc-build.yaml
67-
"wasp-cli-${{ runner.os == 'Linux' && 'linux' || 'macos' }}-${{ runner.arch == 'ARM64' && 'aarch64' || 'x86_64' }}"
69+
ARTIFACT_NAME: ${{ steps.compute-artifact-names.outputs.artifact-name }}
70+
71+
outputs:
72+
artifact-path:
73+
description: "The path to the downloaded artifact directory."
74+
value: ${{ inputs.output-dir }}/${{ steps.compute-artifact-names.outputs.artifact-name }}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: "(Template) Build - Wasp CLI binaries"
2+
3+
# We never trigger this workflow directly.
4+
# We only call it from other workflows (workflow_call).
5+
on:
6+
workflow_call:
7+
inputs:
8+
build-name: { type: string, required: true }
9+
runner: { type: string, required: true }
10+
container: { type: string }
11+
node-version: { type: string }
12+
static: { type: boolean, default: false }
13+
install-deps: { type: string }
14+
15+
env:
16+
WASP_TELEMETRY_DISABLE: 1
17+
18+
jobs:
19+
build:
20+
runs-on: ${{ inputs.runner }}
21+
container: ${{ inputs.container }}
22+
23+
steps:
24+
- uses: actions/checkout@v5
25+
26+
- uses: ./.github/actions/compute-artifact-names
27+
id: compute-artifact-names
28+
with:
29+
build-name: ${{ inputs.build-name }}
30+
31+
- name: Install dependencies
32+
if: ${{ inputs.install-deps }}
33+
run: ${{ inputs.install-deps }}
34+
35+
- uses: ./.github/actions/setup-haskell
36+
with:
37+
extra-cache-key-segment: ${{ inputs.static && 'static' || 'default' }}
38+
39+
- uses: actions/setup-node@v5
40+
if: ${{ inputs.node-version }}
41+
with:
42+
node-version: ${{ inputs.node-version }}
43+
44+
- name: Build and package
45+
working-directory: waspc
46+
env:
47+
LC_ALL: C.UTF-8 # In some Docker containers the LOCALE is not UTF-8 by default
48+
run: |
49+
./run build:all${{ inputs.static && ':static' || '' }}
50+
mkdir -p artifacts
51+
./tools/make_binary_package.sh "artifacts/${{ steps.compute-artifact-names.outputs.tarball-name}}"
52+
53+
- uses: actions/upload-artifact@v4
54+
with:
55+
path: ./waspc/artifacts/${{ steps.compute-artifact-names.outputs.tarball-name}}
56+
name: ${{ steps.compute-artifact-names.outputs.artifact-name}}
57+
if-no-files-found: error
58+
59+
outputs:
60+
tarball-name: ${{ steps.compute-artifact-names.outputs.tarball-name }}
61+
artifact-name: ${{ steps.compute-artifact-names.outputs.artifact-name }}

.github/workflows/ci-waspc-build.yaml

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ env:
2222

2323
jobs:
2424
build:
25+
outputs:
26+
output_linux-x86_64: ${{ steps.set-outputs.outputs.output_linux-x86_64 }}
27+
output_linux-x86_64-static: ${{ steps.set-outputs.outputs.output_linux-x86_64-static }}
28+
output_macos-x86_64: ${{ steps.set-outputs.outputs.output_macos-x86_64 }}
29+
output_macos-aarch64: ${{ steps.set-outputs.outputs.output_macos-aarch64 }}
30+
2531
strategy:
2632
fail-fast: false
2733

@@ -92,6 +98,11 @@ jobs:
9298
steps:
9399
- uses: actions/checkout@v5
94100

101+
- uses: ./.github/actions/compute-artifact-names
102+
id: compute-artifact-names
103+
with:
104+
build-name: ${{ matrix.env.name }}
105+
95106
- name: Install dependencies
96107
if: ${{ matrix.env.install-deps }}
97108
run: ${{ matrix.env.install-deps }}
@@ -112,52 +123,68 @@ jobs:
112123
run: |
113124
./run build:all${{ matrix.env.static && ':static' || '' }}
114125
mkdir -p artifacts
115-
./tools/make_binary_package.sh "artifacts/wasp-${{ matrix.env.name }}.tar.gz"
126+
./tools/make_binary_package.sh "artifacts/${{ steps.compute-artifact-names.outputs.tarball-name }}"
116127
117128
- uses: actions/upload-artifact@v4
118129
with:
119-
path: ./waspc/artifacts/*
120-
name:
121-
"wasp-cli-${{ matrix.env.name }}"
122-
# This name must be in sync with the artifact name used in:
123-
# /.github/actions/fetch-nightly-cli/action.yaml
130+
path: ./waspc/artifacts/${{ steps.compute-artifact-names.outputs.tarball-name }}
131+
name: ${{ steps.compute-artifact-names.outputs.artifact-name }}
124132
if-no-files-found: error
125133

134+
- id: set-outputs
135+
name: Set job outputs
136+
run: |
137+
echo "output_${{ matrix.env.name }}=${{ toJson(steps.compute-artifact-names.outputs.artifact-name) }}" >> $GITHUB_OUTPUT
138+
126139
build-universal:
127140
name: Build Wasp (universal)
128141
needs: build
129142
runs-on: macos-15
130143
steps:
131-
- name: Download macOS binaries
144+
- uses: actions/checkout@v6
145+
146+
- uses: ./.github/actions/compute-artifact-names
147+
id: compute-artifact-names
148+
with:
149+
build-name: macos-universal
150+
151+
- name: Download macOS Intel binaries
152+
uses: actions/download-artifact@v5
153+
with:
154+
name: "${{ needs.build.outputs.output_macos-x86_64.artifact-name }}"
155+
156+
- name: Download macOS ARM binaries
132157
uses: actions/download-artifact@v5
133158
with:
134-
pattern: wasp-cli-macos-*
159+
name: "${{ needs.build.outputs.output_macos-aarch64.artifact-name }}"
135160

136161
- name: Unpack, create universal binary and pack
137162
run: |
138163
set -ex # Fail on error and print each command
139164
140-
input_arch=(
141-
macos-x86_64
142-
macos-aarch64
165+
input_files=(
166+
"${{ needs.build.outputs.output_macos-x86_64.tarball-name }}"
167+
"${{ needs.build.outputs.output_macos-aarch64.tarball-name }}"
143168
)
144169
145170
# Extract each architecture
146-
for arch in "${input_arch[@]}"; do
147-
mkdir "arch-$arch"
148-
tar -xzf "wasp-cli-${arch}/wasp-${arch}.tar.gz" -C "arch-$arch"
171+
i=0;
172+
for file in "${input_files[@]}"; do
173+
mkdir "arch-$i"
174+
tar -xzf $file -C "arch-$i"
175+
i=$((i + 1))
149176
done
150177
151178
mkdir universal
152179
# Create the universal binary
153180
lipo -create arch-*/wasp-bin -output universal/wasp-bin
154-
# Copy the data folder too
155-
cp -R "arch-${input_arch[0]}/data" universal/
181+
# Copy the data folder too (we take the first one, should be identical in both)
182+
cp -R "arch-0/data" universal/
156183
157184
# Pack back up
158-
tar -czf wasp-macos-universal.tar.gz -C universal .
185+
tar -czf ${{ steps.compute-artifact-names.outputs.tarball-name }} -C universal .
159186
160187
- uses: actions/upload-artifact@v4
161188
with:
162-
name: wasp-cli-macos-universal
163-
path: ./wasp-macos-universal.tar.gz
189+
name: ${{ steps.compute-artifact-names.outputs.artifact-name }}
190+
path: ./${{ steps.compute-artifact-names.outputs.tarball-name }}

0 commit comments

Comments
 (0)