2022-08-09 02:50:24 +03:00
|
|
|
name: build
|
2022-11-04 15:59:20 +03:00
|
|
|
|
2022-08-09 02:50:24 +03:00
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
projects:
|
|
|
|
required: true
|
|
|
|
type: string
|
2023-02-03 01:13:38 +03:00
|
|
|
platform:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
new-version:
|
|
|
|
type: boolean
|
|
|
|
required: false
|
|
|
|
default: false
|
2022-08-09 02:50:24 +03:00
|
|
|
|
|
|
|
jobs:
|
2023-02-03 01:13:38 +03:00
|
|
|
get-platform:
|
2023-01-13 00:43:08 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
2023-02-03 01:13:38 +03:00
|
|
|
os: ${{ steps.platform.outputs.os }}
|
|
|
|
build-os: ${{ steps.platform.outputs.build-os }}
|
2023-02-03 01:36:03 +03:00
|
|
|
container: ${{ steps.platform.outputs.container }}
|
2023-02-03 01:13:38 +03:00
|
|
|
test-matrix: ${{ steps.platform.outputs.test-matrix }}
|
2023-02-05 02:49:21 +03:00
|
|
|
cache-set: ${{ steps.platform.outputs.cache-set }}
|
2023-01-13 00:43:08 +03:00
|
|
|
steps:
|
2023-03-11 05:14:21 +03:00
|
|
|
- uses: teaxyz/brewkit/actions/get-platform@v0
|
2023-02-03 01:13:38 +03:00
|
|
|
id: platform
|
2023-02-24 23:50:10 +03:00
|
|
|
with:
|
|
|
|
platform: ${{ inputs.platform }}
|
2023-01-13 00:43:08 +03:00
|
|
|
|
2022-08-09 02:50:24 +03:00
|
|
|
build:
|
2023-02-03 01:13:38 +03:00
|
|
|
runs-on: ${{ fromJson(needs.get-platform.outputs.build-os) }}
|
2023-02-03 01:36:03 +03:00
|
|
|
container: ${{ fromJson(needs.get-platform.outputs.container) }}
|
2023-02-03 01:13:38 +03:00
|
|
|
needs: [get-platform]
|
2022-08-09 02:50:24 +03:00
|
|
|
steps:
|
2023-02-02 17:00:52 +03:00
|
|
|
- uses: actions/checkout@v3
|
2023-02-11 17:59:00 +03:00
|
|
|
|
2023-03-11 05:14:21 +03:00
|
|
|
- uses: teaxyz/brewkit/actions/setup-brewkit@v0
|
2022-10-28 01:23:32 +03:00
|
|
|
id: tea
|
|
|
|
with:
|
|
|
|
prefix: /opt
|
|
|
|
|
2023-02-02 17:00:52 +03:00
|
|
|
- name: sanitize macOS runners
|
2023-02-18 05:07:30 +03:00
|
|
|
if: fromJson(needs.get-platform.outputs.build-os) == 'macos-11'
|
2023-02-02 17:00:52 +03:00
|
|
|
run: sudo mv /usr/local/bin/* /tmp/
|
|
|
|
|
2023-02-24 23:50:10 +03:00
|
|
|
- run: pkg build ${{ inputs.projects }}
|
2022-08-09 02:50:24 +03:00
|
|
|
id: build
|
|
|
|
env:
|
2022-11-11 04:42:08 +03:00
|
|
|
GITHUB_TOKEN: ${{ github.token }}
|
2022-08-09 02:50:24 +03:00
|
|
|
FORCE_UNSAFE_CONFIGURE: 1 # some configure scripts refuse to run as root
|
|
|
|
|
2023-02-22 02:23:47 +03:00
|
|
|
- run: |
|
|
|
|
ABS_PATHS=$(echo $PATHS | tr ' ' '\n' | sed -e "s_^_$TEA_PREFIX/_" | tr '\n' ' ')
|
|
|
|
echo "paths=$ABS_PATHS" >> $GITHUB_OUTPUT
|
|
|
|
if: startsWith(inputs.platform, 'darwin+')
|
|
|
|
id: absolute-paths
|
|
|
|
env:
|
|
|
|
PATHS: ${{ steps.build.outputs.relative-paths }}
|
|
|
|
TEA_PREFIX: ${{ steps.tea.outputs.prefix }}
|
|
|
|
|
|
|
|
# sign macOS binaries
|
2023-03-11 05:14:21 +03:00
|
|
|
- uses: teaxyz/brewkit/actions/codesign@v0
|
2023-02-23 03:07:17 +03:00
|
|
|
if: startsWith(inputs.platform, 'darwin+') && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
|
2023-02-22 02:23:47 +03:00
|
|
|
with:
|
|
|
|
p12-file-base64: ${{ secrets.APPLE_CERTIFICATE_P12 }}
|
|
|
|
p12-password: ${{ secrets.APPLE_CERTIFICATE_P12_PASSWORD }}
|
|
|
|
identity: "Developer ID Application: Tea Inc. (7WV56FL599)"
|
|
|
|
paths: ${{ steps.absolute-paths.outputs.paths }}
|
|
|
|
|
2022-12-21 00:54:26 +03:00
|
|
|
# cache data we'll need in the bottling job
|
2023-02-02 17:00:52 +03:00
|
|
|
- name: assemble artifact metadata
|
|
|
|
run: |
|
2022-12-21 00:54:26 +03:00
|
|
|
echo ${{ steps.build.outputs.pkgs }} >built
|
2023-03-03 01:38:39 +03:00
|
|
|
echo ${{ steps.build.outputs.srcs-relative-paths }} >srcs
|
2022-12-21 00:54:26 +03:00
|
|
|
working-directory: ${{ steps.tea.outputs.prefix }}
|
|
|
|
|
2022-09-29 19:07:07 +03:00
|
|
|
# tarring ourselves ∵ GHA-artifacts (ludicrously) lose permissions
|
|
|
|
# /ref https://github.com/actions/upload-artifact/issues/38
|
2023-02-02 17:00:52 +03:00
|
|
|
- name: create artifacts.tgz
|
|
|
|
run:
|
2023-02-11 17:59:00 +03:00
|
|
|
tar czvf $GITHUB_WORKSPACE/artifacts.tgz
|
2022-10-17 20:45:32 +03:00
|
|
|
${{ steps.build.outputs.relative-paths }}
|
2022-10-17 22:20:42 +03:00
|
|
|
${{ steps.build.outputs.srcs-relative-paths }}
|
2023-02-22 02:23:47 +03:00
|
|
|
built srcs
|
2022-09-29 19:07:07 +03:00
|
|
|
working-directory: ${{ steps.tea.outputs.prefix }}
|
|
|
|
|
2022-09-10 11:09:40 +03:00
|
|
|
- name: upload artifacts
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
2023-02-03 01:13:38 +03:00
|
|
|
name: ${{ inputs.platform }}
|
2022-09-29 19:07:07 +03:00
|
|
|
path: artifacts.tgz
|
2022-09-10 11:09:40 +03:00
|
|
|
if-no-files-found: error
|
|
|
|
|
2022-09-28 18:14:46 +03:00
|
|
|
test:
|
2023-02-03 01:13:38 +03:00
|
|
|
needs: [get-platform, build]
|
2022-12-21 00:54:26 +03:00
|
|
|
runs-on: ${{ matrix.platform.os }}
|
2022-09-08 23:40:35 +03:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-02-03 01:13:38 +03:00
|
|
|
platform: ${{ fromJson(needs.get-platform.outputs.test-matrix) }}
|
2023-01-06 03:05:18 +03:00
|
|
|
outputs:
|
2023-01-12 01:00:05 +03:00
|
|
|
HAS_SECRETS: ${{ env.HAS_SECRETS }}
|
2022-12-21 00:54:26 +03:00
|
|
|
container: ${{ matrix.platform.container }}
|
2022-09-08 23:40:35 +03:00
|
|
|
steps:
|
2022-09-29 02:19:56 +03:00
|
|
|
- uses: actions/checkout@v3
|
2023-03-11 05:14:21 +03:00
|
|
|
- uses: teaxyz/brewkit/actions/setup-brewkit@v0
|
2022-10-26 04:55:49 +03:00
|
|
|
|
2023-02-11 13:52:24 +03:00
|
|
|
- uses: teaxyz/setup@v0
|
2023-02-22 16:11:06 +03:00
|
|
|
with:
|
|
|
|
srcroot: null
|
2022-09-08 23:40:35 +03:00
|
|
|
|
2022-09-28 18:14:46 +03:00
|
|
|
- uses: actions/download-artifact@v3
|
2022-09-08 23:40:35 +03:00
|
|
|
with:
|
2023-02-03 01:13:38 +03:00
|
|
|
name: ${{ inputs.platform }}
|
2022-09-08 23:40:35 +03:00
|
|
|
|
2023-03-04 02:09:23 +03:00
|
|
|
- name: clean destination
|
|
|
|
# Note: needed when changing a directory to a symlink, for example in
|
2023-03-04 01:30:33 +03:00
|
|
|
# https://github.com/teaxyz/pantry.extra/pull/435
|
2023-03-04 02:09:23 +03:00
|
|
|
run: |
|
2023-03-04 03:17:12 +03:00
|
|
|
tar tzf $GITHUB_WORKSPACE/artifacts.tgz | \
|
2023-03-04 02:09:23 +03:00
|
|
|
awk '{ print length, $0 }' | \
|
|
|
|
sort -n -s -r | \
|
|
|
|
cut -d" " -f2- | \
|
|
|
|
xargs rm -rf
|
2023-03-04 02:23:29 +03:00
|
|
|
working-directory: ${{ env.TEA_PREFIX }}
|
2023-03-04 02:09:23 +03:00
|
|
|
|
|
|
|
- name: extract bottles
|
2023-03-04 02:18:05 +03:00
|
|
|
run: tar xzvf artifacts.tgz -C $TEA_PREFIX
|
2022-09-29 19:07:07 +03:00
|
|
|
|
2023-02-24 23:50:10 +03:00
|
|
|
- run: pkg test ${{ inputs.projects }}
|
2023-02-02 17:00:52 +03:00
|
|
|
env:
|
2023-02-24 23:50:10 +03:00
|
|
|
GITHUB_TOKEN: ${{ github.token }}
|
2023-03-10 03:11:11 +03:00
|
|
|
# FIXME: this shouldn't be necessary, but it currently is for the
|
|
|
|
# ubuntu+container test matrix entries. :/
|
|
|
|
TEA_PANTRY_PATH: ${{ github.workspace }}
|
2022-09-08 23:40:35 +03:00
|
|
|
|
2023-02-24 23:50:10 +03:00
|
|
|
- name: '[post]'
|
2023-02-02 17:00:52 +03:00
|
|
|
run:
|
2023-01-12 01:00:05 +03:00
|
|
|
echo "HAS_SECRETS=$HAS_SECRETS" >>$GITHUB_ENV
|
|
|
|
env:
|
|
|
|
HAS_SECRETS: ${{ secrets.AWS_S3_CACHE != null }}
|
|
|
|
|
2023-02-03 04:07:32 +03:00
|
|
|
bottle:
|
|
|
|
needs: [test]
|
|
|
|
if: inputs.new-version == true
|
|
|
|
uses: ./.github/workflows/bottle.yml
|
|
|
|
with:
|
|
|
|
new-version: ${{ inputs.new-version }}
|
|
|
|
platform: ${{ inputs.platform }}
|
|
|
|
secrets: inherit
|
|
|
|
|
|
|
|
complain:
|
|
|
|
needs: [test]
|
|
|
|
if: inputs.new-version == true && failure()
|
|
|
|
uses: ./.github/workflows/complain.yml
|
|
|
|
with:
|
|
|
|
projects: ${{ inputs.projects }}
|
|
|
|
platform: ${{ inputs.platform }}
|
|
|
|
secrets: inherit
|
|
|
|
|
2022-12-21 00:54:26 +03:00
|
|
|
stage:
|
|
|
|
needs: [test]
|
2023-01-06 02:31:35 +03:00
|
|
|
# this only works for PRs from our team to our repo (security! :( )
|
2023-01-12 01:00:05 +03:00
|
|
|
if: startsWith(github.ref, 'refs/pull/') && startsWith(github.repository, 'teaxyz/pantry.') && needs.test.outputs.HAS_SECRETS == 'true'
|
2022-12-21 00:54:26 +03:00
|
|
|
runs-on: ubuntu-latest
|
2022-09-26 17:56:15 +03:00
|
|
|
steps:
|
2022-09-28 18:14:46 +03:00
|
|
|
- uses: actions/download-artifact@v3
|
2022-09-26 17:56:15 +03:00
|
|
|
with:
|
2023-02-03 01:13:38 +03:00
|
|
|
name: ${{ inputs.platform }}
|
2022-12-07 22:33:13 +03:00
|
|
|
|
2023-03-11 05:14:21 +03:00
|
|
|
- uses: teaxyz/brewkit/actions/stage-build-artifacts@v0
|
2023-02-24 23:50:10 +03:00
|
|
|
with:
|
|
|
|
platform: ${{ inputs.platform }}
|
|
|
|
AWS_S3_BUCKET: ${{ secrets.AWS_S3_CACHE }}
|
2022-09-28 18:14:46 +03:00
|
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|