refactor: building of docker images is more flexible #5
This file contains hidden or 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: release-scip | |
on: | |
push: | |
branches: | |
scip | |
tags: | |
- v* | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
cache: npm | |
node-version: 16 | |
registry-url: https://registry.npmjs.org | |
- run: npm install | |
- run: npm install && npm run build | |
working-directory: ./packages/pyright-scip/ | |
- if: ${{ env.NODE_AUTH_TOKEN }} | |
run: npm publish --access public | |
working-directory: ./packages/pyright-scip/ | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
docker: | |
needs: publish | |
strategy: | |
fail-fast: false | |
matrix: | |
version_debian: [bookworm] | |
version_python: [3.10] | |
version_node: [16] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/login-action@v3 | |
with: | |
registry: ${{ vars.REGISTRY || null }} | |
username: ${{ secrets.DOCKER_USERNAME || github.actor }} | |
password: ${{ secrets.DOCKER_PASSWORD || secrets.GITHUB_TOKEN }} | |
# We build over more platforms and hence need QEMU and more control! | |
- uses: docker/setup-qemu-action@v3 | |
- uses: docker/setup-buildx-action@v3 | |
- name: Generate image tags | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: ${{ vars.REGISTRY || 'docker.io' }}/${{ github.repository }} | |
flavor: | | |
latest=true | |
tags: | | |
type=schedule | |
type=ref,event=tag | |
type=sha, | |
type=raw,value=autoindex | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
sourcegraph/scip-python:autoindex | |
sourcegraph/scip-python:latest | |
sourcegraph/scip-python:${{ github.ref_name }} | |
- name: Build and release image | |
id: push | |
uses: docker/build-push-action@v5 | |
with: | |
context: images | |
file: Dockerfile | |
cache-from: type=gha,scope=docker-${{ matrix.version_debian}}-${{ matrix.version_python}}-${{ matrix.version_node }} | |
cache-to: type=gha,mode=max,scope=docker-${{ matrix.version_debian}}-${{ matrix.version_python}}-${{ matrix.version_node }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: linux/amd64,linux/arm64 | |
build-args: |- | |
VERSION_DEBIAN=${{ matrix.version_debian }} | |
VERSION_PYTHON=${{ matrix.version_python }} | |
VERSION_NODE=${{ matrix.version_node }} | |
VERSION_SCIP_PYTHON=${{ github.ref_name }} | |
- name: Generate artifact attestation | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-name: ${{ vars.REGISTRY || 'docker.io' }}/${{ github.repository }} | |
subject-digest: ${{ steps.push.outputs.digest }} | |
push-to-registry: true |