name: Docker image on: push: branches: [main, master, beta] workflow_dispatch: permissions: contents: write # om de versietag te kunnen zetten packages: write # Builds na elkaar uitvoeren, zodat versienummers niet dubbel worden uitgegeven. concurrency: group: docker-build cancel-in-progress: false env: IMAGE: ghcr.io/${{ github.repository }} jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Versienummer bepalen id: ver run: | git fetch --tags --force echo "version=$(tools/next-version.sh)" >> "$GITHUB_OUTPUT" echo "sha=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT" - uses: actions/setup-node@v4 with: node-version: 22 cache: npm - run: npm ci - run: npm test - uses: docker/setup-qemu-action@v3 - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - id: meta uses: docker/metadata-action@v5 with: images: ${{ env.IMAGE }} tags: | type=raw,value=latest,enable={{is_default_branch}} type=sha type=raw,value=beta,enable=${{ github.ref == 'refs/heads/beta' }} type=raw,value=v${{ steps.ver.outputs.version }},enable=${{ github.ref != 'refs/heads/beta' }} - uses: docker/build-push-action@v6 with: context: . platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-args: | APP_VERSION=${{ steps.ver.outputs.version }}${{ github.ref == 'refs/heads/beta' && '-beta' || '' }} GIT_SHA=${{ github.sha }} cache-from: type=gha cache-to: type=gha,mode=max # Pas na een geslaagde build het versienummer vastleggen als tag (voorkomt gaten door mislukte builds). - name: Versietag zetten if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' run: | git tag "v${{ steps.ver.outputs.version }}" "$GITHUB_SHA" git push origin "v${{ steps.ver.outputs.version }}" # Officiƫle release notes (nieuwe functies en opgeloste problemen uit de gemergde PR's). Een fout hier mag # de gepubliceerde image nooit blokkeren, daarom continue-on-error. - name: GitHub Release if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' continue-on-error: true env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: sh tools/publish-release.sh "v${{ steps.ver.outputs.version }}"