Build fixes for new version scheme #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: Container Image Build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Container Registry | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| # For releases: use semantic version tags | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| # For main branch: use date and commit SHA | |
| type=raw,value={{date 'YYYYMMDD'}}-{{sha}},enable={{is_default_branch}} | |
| # Also tag as latest for main branch | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Build and push multi-arch image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| target: runtime | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| extract-release-binaries: | |
| # Only run this job for tagged releases | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: build-and-push | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| strategy: | |
| matrix: | |
| platform: | |
| - arch: amd64 | |
| platform: linux/amd64 | |
| - arch: arm64 | |
| platform: linux/arm64 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and extract binary for ${{ matrix.platform.arch }} | |
| run: | | |
| mkdir -p build/${{ matrix.platform.arch }} | |
| docker buildx build -f Dockerfile \ | |
| --target export \ | |
| --output type=local,dest=build/${{ matrix.platform.arch }} \ | |
| --platform ${{ matrix.platform.platform }} \ | |
| . | |
| - name: Rename binary with arch suffix | |
| run: | | |
| mv build/${{ matrix.platform.arch }}/libparcagpucupti.so \ | |
| build/${{ matrix.platform.arch }}/libparcagpucupti-${{ matrix.platform.arch }}.so | |
| - name: Upload binary as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: libparcagpucupti-${{ matrix.platform.arch }} | |
| path: build/${{ matrix.platform.arch }}/libparcagpucupti-${{ matrix.platform.arch }}.so | |
| - name: Upload to GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: build/${{ matrix.platform.arch }}/libparcagpucupti-${{ matrix.platform.arch }}.so |