2023-03-14 23:41:37 +03:00
|
|
|
name: build
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
projects:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
platform:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
get-platform:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
os: ${{ steps.platform.outputs.os }}
|
|
|
|
build-os: ${{ steps.platform.outputs.build-os }}
|
|
|
|
container: ${{ steps.platform.outputs.container }}
|
|
|
|
test-matrix: ${{ steps.platform.outputs.test-matrix }}
|
|
|
|
cache-set: ${{ steps.platform.outputs.cache-set }}
|
2023-04-22 00:19:52 +03:00
|
|
|
available: ${{ steps.platform.outputs.available }}
|
2023-03-14 23:41:37 +03:00
|
|
|
steps:
|
2023-09-30 19:15:42 +03:00
|
|
|
- uses: pkgxdev/brewkit/actions/get-platform@v0
|
2023-03-14 23:41:37 +03:00
|
|
|
id: platform
|
|
|
|
with:
|
|
|
|
platform: ${{ inputs.platform }}
|
2023-04-22 00:19:52 +03:00
|
|
|
projects: ${{ inputs.projects }}
|
2023-03-14 23:41:37 +03:00
|
|
|
|
|
|
|
build:
|
|
|
|
runs-on: ${{ fromJson(needs.get-platform.outputs.build-os) }}
|
|
|
|
container: ${{ fromJson(needs.get-platform.outputs.container) }}
|
|
|
|
needs: [get-platform]
|
2023-04-30 04:45:57 +03:00
|
|
|
if: ${{ needs.get-platform.outputs.available != '' }}
|
2023-03-14 23:41:37 +03:00
|
|
|
steps:
|
2023-09-30 19:15:42 +03:00
|
|
|
- uses: actions/checkout@v4
|
2023-03-14 23:41:37 +03:00
|
|
|
|
2023-09-30 19:15:42 +03:00
|
|
|
- uses: pkgxdev/brewkit/actions/setup-brewkit@v0
|
|
|
|
id: pkgx
|
2023-03-14 23:41:37 +03:00
|
|
|
with:
|
|
|
|
prefix: /opt
|
2023-08-06 18:53:50 +03:00
|
|
|
timeout-minutes: 10
|
2023-03-14 23:41:37 +03:00
|
|
|
|
|
|
|
- name: sanitize macOS runners
|
|
|
|
if: fromJson(needs.get-platform.outputs.build-os) == 'macos-11'
|
|
|
|
run: sudo mv /usr/local/bin/* /tmp/
|
|
|
|
|
2023-03-31 17:12:12 +03:00
|
|
|
# setup macOS codesigning
|
2023-09-30 19:15:42 +03:00
|
|
|
- uses: pkgxdev/brewkit/actions/setup-codesign@v0
|
2023-03-31 17:12:12 +03:00
|
|
|
if: startsWith(inputs.platform, 'darwin+') && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
|
|
|
|
with:
|
2023-05-19 01:54:31 +03:00
|
|
|
p12-file-base64: ${{ secrets.APPLE_CERTIFICATE_P12 }}
|
|
|
|
p12-password: ${{ secrets.APPLE_CERTIFICATE_P12_PASSWORD }}
|
2023-03-31 17:12:12 +03:00
|
|
|
|
2023-04-30 04:45:57 +03:00
|
|
|
- run: pkg build ${{ needs.get-platform.outputs.available }}
|
2023-03-14 23:41:37 +03:00
|
|
|
id: build
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ github.token }}
|
2023-05-19 01:54:31 +03:00
|
|
|
FORCE_UNSAFE_CONFIGURE: 1 # some configure scripts refuse to run as root
|
2023-03-31 20:34:35 +03:00
|
|
|
APPLE_IDENTITY: ${{ secrets.APPLE_IDENTITY || '-' }}
|
2023-09-30 19:15:42 +03:00
|
|
|
SRCROOT: ${{ github.workspace }}
|
2023-03-14 23:41:37 +03:00
|
|
|
|
|
|
|
- run: |
|
2023-09-30 19:15:42 +03:00
|
|
|
ABS_PATHS=$(echo $PATHS | tr ' ' '\n' | sed -e "s_^_/opt/_" | tr '\n' ' ')
|
2023-03-14 23:41:37 +03:00
|
|
|
echo "paths=$ABS_PATHS" >> $GITHUB_OUTPUT
|
|
|
|
if: startsWith(inputs.platform, 'darwin+')
|
|
|
|
id: absolute-paths
|
|
|
|
env:
|
|
|
|
PATHS: ${{ steps.build.outputs.relative-paths }}
|
|
|
|
|
|
|
|
# cache data we'll need in the bottling job
|
|
|
|
- name: assemble artifact metadata
|
|
|
|
run: |
|
|
|
|
echo ${{ steps.build.outputs.pkgs }} >built
|
|
|
|
echo ${{ steps.build.outputs.srcs-relative-paths }} >srcs
|
2023-09-30 19:15:42 +03:00
|
|
|
working-directory: /opt
|
2023-03-14 23:41:37 +03:00
|
|
|
|
|
|
|
# tarring ourselves ∵ GHA-artifacts (ludicrously) lose permissions
|
|
|
|
# /ref https://github.com/actions/upload-artifact/issues/38
|
|
|
|
- name: create artifacts.tgz
|
2023-05-19 01:54:31 +03:00
|
|
|
run: tar czvf $GITHUB_WORKSPACE/artifacts.tgz
|
|
|
|
${{ steps.build.outputs.relative-paths }}
|
|
|
|
${{ steps.build.outputs.srcs-relative-paths }}
|
|
|
|
built srcs
|
2023-09-30 19:15:42 +03:00
|
|
|
working-directory: /opt
|
2023-03-14 23:41:37 +03:00
|
|
|
|
|
|
|
- name: upload artifacts
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: ${{ inputs.platform }}
|
|
|
|
path: artifacts.tgz
|
|
|
|
if-no-files-found: error
|
|
|
|
|
|
|
|
test:
|
|
|
|
needs: [get-platform, build]
|
2023-04-30 04:45:57 +03:00
|
|
|
if: ${{ needs.get-platform.outputs.available != '' }}
|
2023-03-14 23:41:37 +03:00
|
|
|
runs-on: ${{ matrix.platform.os }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
platform: ${{ fromJson(needs.get-platform.outputs.test-matrix) }}
|
2023-05-19 01:54:31 +03:00
|
|
|
name: test ${{ matrix.platform.name-extra }}
|
2023-03-14 23:41:37 +03:00
|
|
|
outputs:
|
|
|
|
HAS_SECRETS: ${{ env.HAS_SECRETS }}
|
|
|
|
container: ${{ matrix.platform.container }}
|
|
|
|
steps:
|
2023-09-30 19:15:42 +03:00
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: pkgxdev/brewkit/actions/setup-brewkit@v0
|
2023-08-06 18:53:50 +03:00
|
|
|
timeout-minutes: 10
|
2023-03-14 23:41:37 +03:00
|
|
|
|
|
|
|
- uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: ${{ inputs.platform }}
|
|
|
|
|
|
|
|
- name: clean destination
|
|
|
|
# Note: needed when changing a directory to a symlink, for example in
|
2023-09-30 19:15:42 +03:00
|
|
|
# https://github.com/pkgxdev/pantry/pull/435
|
2023-03-14 23:41:37 +03:00
|
|
|
run: |
|
2023-09-30 19:15:42 +03:00
|
|
|
cd $HOME/.pkgx
|
2023-03-14 23:41:37 +03:00
|
|
|
tar tzf $GITHUB_WORKSPACE/artifacts.tgz | \
|
|
|
|
awk '{ print length, $0 }' | \
|
|
|
|
sort -n -s -r | \
|
|
|
|
cut -d" " -f2- | \
|
|
|
|
xargs rm -rf
|
|
|
|
|
|
|
|
- name: extract bottles
|
2023-09-30 19:15:42 +03:00
|
|
|
run: tar xzvf artifacts.tgz -C $HOME/.pkgx
|
2023-03-14 23:41:37 +03:00
|
|
|
|
2023-04-30 04:45:57 +03:00
|
|
|
- run: pkg test ${{ needs.get-platform.outputs.available }}
|
2023-03-14 23:41:37 +03:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
|
|
# FIXME: this shouldn't be necessary, but it currently is for the
|
|
|
|
# ubuntu+container test matrix entries. :/
|
2023-09-30 19:15:42 +03:00
|
|
|
PKGX_PANTRY_PATH: ${{ github.workspace }}
|
2023-03-14 23:41:37 +03:00
|
|
|
|
2023-05-19 01:54:31 +03:00
|
|
|
- name: "[post]"
|
|
|
|
run: echo "HAS_SECRETS=$HAS_SECRETS" >>$GITHUB_ENV
|
2023-03-14 23:41:37 +03:00
|
|
|
env:
|
|
|
|
HAS_SECRETS: ${{ secrets.AWS_S3_CACHE != null }}
|
|
|
|
|
|
|
|
stage:
|
2023-04-22 00:19:52 +03:00
|
|
|
needs: [get-platform, test]
|
2023-03-14 23:41:37 +03:00
|
|
|
# this only works for PRs from our team to our repo (security! :( )
|
2023-09-30 19:15:42 +03:00
|
|
|
if: startsWith(github.ref, 'refs/pull/') && github.repository_owner == 'pkgxdev' && needs.test.outputs.HAS_SECRETS == 'true' && needs.get-platform.outputs.available != ''
|
2023-03-14 23:41:37 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: ${{ inputs.platform }}
|
|
|
|
|
2023-09-30 19:15:42 +03:00
|
|
|
- uses: pkgxdev/brewkit/actions/stage-build-artifacts@v0
|
2023-03-14 23:41:37 +03:00
|
|
|
with:
|
|
|
|
platform: ${{ inputs.platform }}
|
|
|
|
AWS_S3_BUCKET: ${{ secrets.AWS_S3_CACHE }}
|
|
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|