diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e5f9a0b..dd91dc7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,4 +78,74 @@ jobs: src/build/release/ocf-amd64 src/build/release/ocf-arm64 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-docker-images: + runs-on: ubuntu-22.04 + needs: build + strategy: + fail-fast: false + matrix: + include: + - dockerfile: ./docker/dispatcher/Dockerfile + image: ocf + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Get release version + id: get_version + run: | + echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: Checkout release tag + run: | + git fetch --tags --all --force + git checkout tags/${{ env.RELEASE_TAG }} + + # Set up BuildKit Docker container builder to be able to build + # multi-platform images and export cache + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 + with: + images: ${{ env.REGISTRY }}/${{ matrix.image }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 + with: + context: . + file: ${{ matrix.dockerfile }} + push: true + tags: ${{ steps.meta.outputs.tags }} + platforms: linux/amd64,linux/arm64 + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + build-args: | + VERSION=${{ env.RELEASE_TAG }} \ No newline at end of file diff --git a/docker/dispatcher/Dockerfile b/docker/dispatcher/Dockerfile new file mode 100644 index 0000000..86b6b25 --- /dev/null +++ b/docker/dispatcher/Dockerfile @@ -0,0 +1,19 @@ + +FROM alpine:edge + +ARG VERSION + +WORKDIR /app + +RUN case "$TARGETPLATFORM" in \ + "linux/amd64") URL="https://github.com/ResearchComputer/OpenComputeFramework/releases/download/${{VERSION}}/ocf-amd64" ;; \ + "linux/arm64") URL="https://github.com/ResearchComputer/OpenComputeFramework/releases/download/${{VERSION}}/ocf-arm64" ;; \ + *) echo "Unsupported platform: $TARGETPLATFORM" && exit 1 ;; \ + esac && \ + curl -L "$URL" > ocf && \ + chmod +x ocf + + +RUN apk --no-cache add ca-certificates tzdata + +ENTRYPOINT ["/app/ocf"] \ No newline at end of file