Feature/multiarch #33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "MetaCall Distributable Linux Release" | |
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
tags: | |
- 'v*.*.*' | |
branches: | |
- master | |
env: | |
GHR_VERSION: 0.17.0 | |
# GITHUB_TOKEN - From default secrets | |
# GITHUB_REPOSITORY - Default variable | |
jobs: | |
build: | |
name: Build and Package | |
runs-on: ubuntu-latest | |
timeout-minutes: 360 | |
strategy: | |
matrix: | |
arch: [amd64, 386] | |
steps: | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: all | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Set asset name | |
run: echo "ASSET_NAME=metacall-tarball-linux-${{ matrix.arch }}.tar.gz" >> $GITHUB_ENV | |
- name: Build the Docker image for ${{ matrix.arch }} | |
run: | | |
docker buildx build \ | |
--platform linux/${{ matrix.arch }} \ | |
-t metacall/distributable_linux:${{ matrix.arch }} \ | |
--load \ | |
-f Dockerfile . | |
- name: Install additional channels and pull for ${{ matrix.arch }} | |
run: | | |
docker run --privileged --name tmp metacall/distributable_linux:${{ matrix.arch }} sh -c 'guix pull' | |
docker commit tmp metacall/distributable_linux:${{ matrix.arch }} | |
docker rm -f tmp | |
- name: Build dependencies for ${{ matrix.arch }} | |
run: | | |
docker run -d --privileged --name tmp metacall/distributable_linux:${{ matrix.arch }} /metacall/scripts/deps.sh | |
docker commit tmp metacall/distributable_linux:${{ matrix.arch }} | |
docker rm -f tmp | |
- name: Build tarball for ${{ matrix.arch }} | |
run: | | |
docker run --rm -e ARCH=${{ matrix.arch }} -v $PWD/out:/metacall/pack --privileged metacall/distributable_linux:${{ matrix.arch }} /metacall/scripts/build.sh | |
- name: Verify tarball creation | |
run: ls -lh out/ | |
- name: Upload tarball artifact for ${{ matrix.arch }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: built-tarball-${{ matrix.arch }} | |
path: out/${{ env.ASSET_NAME }} | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
matrix: | |
arch: [amd64, 386] | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Download tarball artifact for ${{ matrix.arch }} | |
uses: actions/download-artifact@v4 | |
with: | |
name: built-tarball-${{ matrix.arch }} | |
path: out/ | |
- name: Generate a unique ID for invalidating the cache of test layers | |
run: echo "CACHE_INVALIDATE=$(date +%s)" >> $GITHUB_ENV | |
- name: Test CLI for ${{ matrix.arch }} | |
run: | | |
docker buildx build \ | |
--platform linux/${{ matrix.arch }} \ | |
--build-arg ARCH=${{ matrix.arch }} \ | |
--build-arg CACHE_INVALIDATE=${{ env.CACHE_INVALIDATE }} \ | |
-t metacall/distributable_linux_test:cli-${{ matrix.arch }} \ | |
-f tests/cli/Dockerfile . | |
- name: Test C for ${{ matrix.arch }} | |
run: | | |
docker buildx build \ | |
--platform linux/${{ matrix.arch }} \ | |
--build-arg ARCH=${{ matrix.arch }} \ | |
--build-arg CACHE_INVALIDATE=${{ env.CACHE_INVALIDATE }} \ | |
-t metacall/distributable_linux_test:c-${{ matrix.arch }} \ | |
-f tests/c/Dockerfile . | |
- name: Test Python for ${{ matrix.arch }} | |
run: | | |
docker buildx build \ | |
--platform linux/${{ matrix.arch }} \ | |
--build-arg ARCH=${{ matrix.arch }} \ | |
--build-arg CACHE_INVALIDATE=${{ env.CACHE_INVALIDATE }} \ | |
-t metacall/distributable_linux_test:python-${{ matrix.arch }} \ | |
-f tests/python/Dockerfile . | |
- name: Test Node for ${{ matrix.arch }} | |
run: | | |
docker buildx build \ | |
--platform linux/${{ matrix.arch }} \ | |
--build-arg ARCH=${{ matrix.arch }} \ | |
--build-arg CACHE_INVALIDATE=${{ env.CACHE_INVALIDATE }} \ | |
-t metacall/distributable_linux_test:node-${{ matrix.arch }} \ | |
-f tests/node/Dockerfile . | |
- name: Test TypeScript for ${{ matrix.arch }} | |
run: | | |
docker buildx build \ | |
--platform linux/${{ matrix.arch }} \ | |
--build-arg ARCH=${{ matrix.arch }} \ | |
--build-arg CACHE_INVALIDATE=${{ env.CACHE_INVALIDATE }} \ | |
-t metacall/distributable_linux_test:typescript-${{ matrix.arch }} \ | |
-f tests/typescript/Dockerfile . | |
publish-github: | |
name: Publish on GitHub | |
runs-on: ubuntu-latest | |
needs: test | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download tarball artifacts for all architectures | |
uses: actions/download-artifact@v4 | |
with: | |
name: built-tarball-${{ matrix.arch }} | |
path: out/ | |
- name: Load GHR binary | |
run: | | |
curl -sL https://github.com/tcnksm/ghr/releases/download/v${GHR_VERSION}/ghr_v${GHR_VERSION}_linux_amd64.tar.gz | tar zx | |
chmod +x ghr_v${GHR_VERSION}_linux_amd64/ghr | |
mv ghr_v${GHR_VERSION}_linux_amd64/ghr /usr/local/bin | |
- name: Export variables | |
run: | | |
echo "GH_REPO_OWNER=${GITHUB_REPOSITORY_OWNER}" >> $GITHUB_ENV | |
echo "GH_REPO_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV | |
export PREVIOUS_TAG=$(git describe HEAD^1 --abbrev=0 --tags) | |
echo "PREVIOUS_TAG=${PREVIOUS_TAG}" >> $GITHUB_ENV | |
echo "GIT_HISTORY<<EOF" >> $GITHUB_ENV | |
echo "$(git log --no-merges --format="- %s" ${PREVIOUS_TAG}..HEAD)" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Publish package to GitHub Releases | |
run: | | |
if [[ "${PREVIOUS_TAG}" == "" ]]; then export GIT_HISTORY=$(git log --no-merges --format="- %s"); fi | |
export CI_COMMIT_TAG="${{ github.ref_name }}" | |
export RELEASE_DATE=$(date '+%Y-%m-%d') | |
mv ${PWD}/out/${{ env.ASSET_NAME }} ${PWD}/out/${{ env.ASSET_NAME }} | |
echo "MetaCall Distributable Linux ${CI_COMMIT_TAG} [${RELEASE_DATE}] - ${GH_REPO_OWNER}/${GH_REPO_NAME}:${CI_COMMIT_SHA}" && echo "${GIT_HISTORY}" | |
ghr -t "${{ secrets.GITHUB_TOKEN }}" -u "${GH_REPO_OWNER}" -r "${GH_REPO_NAME}" -c "${CI_COMMIT_SHA}" -n "MetaCall Distributable Linux ${CI_COMMIT_TAG} [${RELEASE_DATE}]" -b "${GIT_HISTORY}" -replace "${CI_COMMIT_TAG}" ${PWD}/out/${{ env.ASSET_NAME }} | |
install-test: | |
name: Trigger Install Test Workflow | |
runs-on: ubuntu-latest | |
needs: publish-github | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- uses: convictional/[email protected] | |
with: | |
owner: metacall | |
repo: install | |
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
workflow_file_name: test-linux.yml | |
wait_workflow: true | |
ref: master |