Container Publish #3
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 Publish | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Container version tag to publish" | |
| required: true | |
| default: "0.1.2" | |
| publish_latest: | |
| description: "Also publish the latest tag" | |
| required: true | |
| type: boolean | |
| default: true | |
| permissions: | |
| contents: read | |
| packages: write | |
| attestations: write | |
| id-token: write | |
| jobs: | |
| ghcr: | |
| name: Publish GHCR paper image | |
| runs-on: ubuntu-latest | |
| env: | |
| IMAGE_NAME: ghcr.io/zero-intel/zero-paper | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| steps: | |
| - uses: actions/checkout@v6.0.2 | |
| - name: Build local smoke image | |
| run: docker build -t zero-paper-smoke:${{ github.sha }} . | |
| - name: Smoke local image | |
| run: | | |
| docker run --rm zero-paper-smoke:${{ github.sha }} | |
| docker run --rm zero-paper-smoke:${{ github.sha }} python /app/examples/paper-trading/run.py | |
| - uses: docker/setup-qemu-action@v3 | |
| - uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| - name: Prepare tags | |
| id: tags | |
| run: | | |
| short_sha="${GITHUB_SHA::7}" | |
| { | |
| echo 'tags<<EOF' | |
| echo "${IMAGE_NAME}:${{ inputs.version }}" | |
| echo "${IMAGE_NAME}:sha-${short_sha}" | |
| if [[ "${{ inputs.publish_latest }}" == "true" ]]; then | |
| echo "${IMAGE_NAME}:latest" | |
| fi | |
| echo 'EOF' | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Build and push multi-platform image | |
| id: push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.tags.outputs.tags }} | |
| labels: | | |
| org.opencontainers.image.title=ZERO Paper Runtime | |
| org.opencontainers.image.description=Paper-first ZERO runtime for self-custodial onchain operations. | |
| org.opencontainers.image.source=https://github.com/zero-intel/zero | |
| org.opencontainers.image.version=${{ inputs.version }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| org.opencontainers.image.licenses=Apache-2.0 | |
| provenance: mode=max | |
| sbom: true | |
| - name: Try to make GHCR package public | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| if gh api \ | |
| --method PATCH \ | |
| /orgs/zero-intel/packages/container/zero-paper/visibility \ | |
| -f visibility=public; then | |
| echo "GHCR package visibility set to public." | |
| else | |
| echo "::warning::GITHUB_TOKEN could not change GHCR package visibility. Make the package public from GitHub Packages settings or rerun with a token that can administer org packages." | |
| fi | |
| - name: Smoke published image | |
| run: | | |
| docker pull "${IMAGE_NAME}:${{ inputs.version }}" | |
| docker run --rm "${IMAGE_NAME}:${{ inputs.version }}" | |
| docker run --rm "${IMAGE_NAME}:${{ inputs.version }}" python /app/examples/paper-trading/run.py | |
| - name: Write publication summary | |
| run: | | |
| { | |
| echo "## GHCR publication" | |
| echo | |
| echo "- Image: \`${IMAGE_NAME}:${{ inputs.version }}\`" | |
| echo "- Digest: \`${{ steps.push.outputs.digest }}\`" | |
| echo "- Platforms: \`linux/amd64,linux/arm64\`" | |
| echo "- Smoke: local image and published image" | |
| } >> "$GITHUB_STEP_SUMMARY" |