Skip to content

Commit 3054aed

Browse files
committed
Write universal binary build job draft; refactor env vars
This expands the stub job for making Universal 2 binaries for macOS into a full definition, downloading and extracting the two architecture-specific archives from the GitHub release. This may require further refinement. It also refactors the way environment variables are set for the preexisting jobs: - Order variables in `env:` so they may be easier to understand. - Define `VERSION` in `env:` rather than in its own step. I think this is a bit more readable, but also, it allows the new job to be stylistically consistent with the preexisting jobs.
1 parent 56d1bbb commit 3054aed

File tree

1 file changed

+36
-14
lines changed

1 file changed

+36
-14
lines changed

.github/workflows/release.yml

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,15 @@ jobs:
134134
runs-on: ${{ matrix.os }}
135135

136136
env:
137+
RUST_BACKTRACE: '1' # Emit backtraces on panics.
138+
CARGO_TERM_COLOR: always
139+
CLICOLOR: '1'
137140
CARGO: cargo # On Linux, this will be changed to `cross` in a later step.
141+
FEATURE: ${{ matrix.feature }}
142+
VERSION: ${{ needs.create-release.outputs.version }}
138143
TARGET: ${{ matrix.target }}
139144
TARGET_FLAGS: --target=${{ matrix.target }}
140145
TARGET_DIR: target/${{ matrix.target }}
141-
FEATURE: ${{ matrix.feature }}
142-
RUST_BACKTRACE: '1' # Emit backtraces on panics.
143-
CARGO_TERM_COLOR: always
144-
CLICOLOR: '1'
145146

146147
steps:
147148
- name: Checkout repository
@@ -192,11 +193,6 @@ jobs:
192193
/target/arm-unknown-linux-gnueabihf/release/ein \
193194
/target/arm-unknown-linux-gnueabihf/release/gix
194195
195-
- name: Determine version
196-
run: echo "VERSION=$VERSION" >> "$GITHUB_ENV"
197-
env:
198-
VERSION: ${{ needs.create-release.outputs.version }}
199-
200196
- name: Determine archive basename
201197
run: echo "ARCHIVE=gitoxide-$FEATURE-$VERSION-$TARGET" >> "$GITHUB_ENV"
202198

@@ -226,8 +222,8 @@ jobs:
226222
env:
227223
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
228224

229-
build-macos-universal-binary-release:
230-
name: build-macos-universal-binary-release
225+
build-macos-universal2-release:
226+
name: build-macos-universal2-release
231227

232228
runs-on: macos-latest
233229

@@ -237,9 +233,35 @@ jobs:
237233
matrix:
238234
feature: [ small, lean, max, max-pure ]
239235

236+
env:
237+
BASH_ENV: ./helpers.sh
238+
FEATURE: ${{ matrix.feature }}
239+
VERSION: ${{ needs.create-release.outputs.version }}
240+
240241
steps:
241-
- name: Placeholder
242+
- name: Define helper function
243+
run: |
244+
name() { echo "gitoxide-$FEATURE-$VERSION-$1-apple-darwin"; }
245+
declare -f name >> "$BASH_ENV"
246+
247+
- name: Obtain single-architecture releases
248+
run: |
249+
gh release download "$VERSION" --pattern="$(name aarch64).tar.gz" --pattern="$(name x86_64).tar.gz"
250+
tar xf "$(name aarch64).tar.gz"
251+
tar xf "$(name x86_64).tar.gz"
252+
253+
- name: Repack into Universal-2 release
242254
run: |
243-
echo "This job is for the feature: $FEATURE"
255+
cp -R -- "$(name aarch64)" "$(name universal)"
256+
rm -- "$(name universal)"/{ein,gix}
257+
for bin in ein gix; do
258+
lipo -create "$(name aarch64)/$bin" "$(name x86_64)/$bin" -output "$(name universal)/$bin"
259+
done
260+
file "$(name universal)"/{ein,gix}
261+
tar czf "$(name universal).tar.gz" "$(name universal)"
262+
echo "ASSET=$(name universal).tar.gz" >> "$GITHUB_ENV"
263+
264+
- name: Upload release archive
265+
run: gh release upload "$VERSION" "$ASSET"
244266
env:
245-
FEATURE: ${{ matrix.feature }}
267+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)