|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + name: Release Container |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: read |
| 14 | + packages: write |
| 15 | + id-token: write |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 18 | + |
| 19 | + - name: Linting |
| 20 | + uses: ./.github/workflows/lint.yml |
| 21 | + |
| 22 | + - name: Tests |
| 23 | + uses: ./.github/workflows/test.yml |
| 24 | + |
| 25 | + - name: Set up Docker Buildx |
| 26 | + uses: docker/setup-buildx-action@v3 |
| 27 | + |
| 28 | + - name: Log in to GitHub Container Registry |
| 29 | + uses: docker/login-action@v3 |
| 30 | + with: |
| 31 | + registry: ghcr.io |
| 32 | + username: ${{ github.actor }} |
| 33 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + |
| 35 | + - name: Extract tag version |
| 36 | + id: tag |
| 37 | + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT |
| 38 | + |
| 39 | + - name: Set repository owner lowercase |
| 40 | + id: repo_owner |
| 41 | + run: echo "OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT |
| 42 | + |
| 43 | + - name: Extract metadata |
| 44 | + id: meta |
| 45 | + uses: docker/metadata-action@v5 |
| 46 | + with: |
| 47 | + images: ghcr.io/${{ steps.repo_owner.outputs.OWNER }}/plotting-mcp |
| 48 | + tags: | |
| 49 | + type=ref,event=tag |
| 50 | + type=raw,value=latest,enable={{is_default_branch}} |
| 51 | + type=raw,value=${{ steps.tag.outputs.VERSION }} |
| 52 | +
|
| 53 | + - name: Build and push container |
| 54 | + uses: docker/build-push-action@v6 |
| 55 | + with: |
| 56 | + context: . |
| 57 | + platforms: linux/amd64,linux/arm64 |
| 58 | + push: true |
| 59 | + tags: ${{ steps.meta.outputs.tags }} |
| 60 | + labels: ${{ steps.meta.outputs.labels }} |
| 61 | + cache-from: type=gha |
| 62 | + cache-to: type=gha,mode=max |
| 63 | + |
| 64 | + - name: Install Cosign |
| 65 | + uses: sigstore/cosign-installer@398d4b0eeef1380460a10c8013a76f728fb906ac # v3.9.1 |
| 66 | + |
| 67 | + - name: Sign container image |
| 68 | + env: |
| 69 | + REGISTRY: ghcr.io/${{ steps.repo_owner.outputs.OWNER }}/plotting-mcp |
| 70 | + run: | |
| 71 | + TAG=$(echo "${{ steps.tag.outputs.VERSION }}" | sed 's/+/_/g') |
| 72 | + # Sign the tagged image |
| 73 | + cosign sign -y $REGISTRY:$TAG |
| 74 | +
|
| 75 | + # Sign the latest tag if building from a tag |
| 76 | + if [[ "${{ github.ref }}" == refs/tags/* ]]; then |
| 77 | + cosign sign -y $REGISTRY:latest |
| 78 | + fi |
0 commit comments