Skip to content

Build and publish

Build and publish #59

name: Build and publish
on:
schedule:
- cron: "0 0 1 * *"
push:
branches: [master]
env:
UBUNTU_VERSION: 22.04
OCCT_VERSION: 7.8.1
CGAL_VERSION: 6.0.1
EIGEN_VERSION: 3.4.0
ASI_VERSION: 1097398d
ASI_VERSION_MODE: commit
RAPIDJSON_VERSION: 1.1.0
NVM_VERSION: 0.40.1
AIS_REPOSITORY_NAME: ghcr.io/michsior14/ubuntu-occt-asi-cgal-eigen-node
REPOSITORY_NAME: ghcr.io/michsior14/ubuntu-occt-cgal-eigen-node
jobs:
build-ubuntu-occt-asi-cgal-eigen-node:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
node: [20, 22]
platform: [linux/amd64, linux/arm64/v8]
steps:
- name: Prepare envs
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
image_name=${{ env.AIS_REPOSITORY_NAME }}
echo "IMAGE_NAME=${image_name//ghcr.io\/michsior14\///}" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
id: build
with:
context: ./tools/${{ env.IMAGE_NAME }}
platforms: ${{ matrix.platform }}
cache-from: type=gha,scope=${{ env.IMAGE_NAME}}-${{ github.ref_name }}-${{ matrix.platform }}
cache-to: type=gha,scope=${{ env.IMAGE_NAME }}-${{ github.ref_name }}-${{ matrix.platform }},mode=max
outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
tags: ${{ env.AIS_REPOSITORY_NAME }}
build-args: |
node_version=${{ matrix.node }}
ubuntu_version=${{ env.UBUNTU_VERSION }}
occt_version=${{ env.OCCT_VERSION }}
cgal_version=${{ env.CGAL_VERSION }}
eigen_version=${{ env.EIGEN_VERSION }}
nvm_version=${{ env.NVM_VERSION }}
rapidjson_version=${{ env.RAPIDJSON_VERSION }}
asi_version=${{ env.ASI_VERSION }}
asi_version_mode=${{ env.ASI_VERSION_MODE }}
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-asi-${{matrix.node}}-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge-ubuntu-occt-asi-cgal-eigen-node:
runs-on: ubuntu-latest
needs:
- build-ubuntu-occt-asi-cgal-eigen-node
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
node: [20, 22]
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-asi-${{matrix.node}}-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.AIS_REPOSITORY_NAME }}@sha256:%s ' *) \
-t ${{ env.AIS_REPOSITORY_NAME }}:node-${{matrix.node}}${{ env.ASI_VERSION_MODE == 'commit' && format('-{0}', env.ASI_VERSION) || ''}} \
-t ${{ env.AIS_REPOSITORY_NAME }}:${{ env.UBUNTU_VERSION }}-occt-${{ env.OCCT_VERSION }}-asi-${{ env.ASI_VERSION }}-cgal-${{ env.CGAL_VERSION }}-eigen-${{ env.EIGEN_VERSION }}-node-${{ matrix.node }}
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.AIS_REPOSITORY_NAME }}:node-${{matrix.node}}${{ env.ASI_VERSION_MODE == 'commit' && format('-{0}', env.ASI_VERSION) || ''}}
build-ubuntu-occt-cgal-eigen-node:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
node: [20, 22]
platform: [linux/amd64, linux/arm64/v8]
steps:
- name: Prepare envs
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
image_name=${{ env.REPOSITORY_NAME }}
echo "IMAGE_NAME=${image_name//ghcr.io\/michsior14\///}" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
id: build
with:
context: ./tools/${{ env.IMAGE_NAME }}
platforms: ${{ matrix.platform }}
cache-from: type=gha,scope=${{ env.IMAGE_NAME}}-${{ github.ref_name }}-${{ matrix.platform }}
cache-to: type=gha,scope=${{ env.IMAGE_NAME }}-${{ github.ref_name }}-${{ matrix.platform }},mode=max
outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
tags: ${{ env.REPOSITORY_NAME }}
build-args: |
node_version=${{ matrix.node }}
ubuntu_version=${{ env.UBUNTU_VERSION }}
occt_version=${{ env.OCCT_VERSION }}
cgal_version=${{ env.CGAL_VERSION }}
eigen_version=${{ env.EIGEN_VERSION }}
nvm_version=${{ env.NVM_VERSION }}
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{matrix.node}}-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge-ubuntu-occt-cgal-eigen-node:
runs-on: ubuntu-latest
needs:
- build-ubuntu-occt-cgal-eigen-node
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
node: [20, 22]
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-${{matrix.node}}-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REPOSITORY_NAME }}@sha256:%s ' *) \
-t ${{ env.REPOSITORY_NAME }}:node-${{matrix.node}} \
-t ${{ env.REPOSITORY_NAME }}:${{ env.UBUNTU_VERSION }}-occt-${{ env.OCCT_VERSION }}-cgal-${{ env.CGAL_VERSION }}-eigen-${{ env.EIGEN_VERSION }}-node-${{ matrix.node }}
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REPOSITORY_NAME }}:node-${{matrix.node}}