|
| 1 | +name: Sysbox Installer Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - 'v*' |
| 8 | +permissions: |
| 9 | + attestations: write |
| 10 | + id-token: write |
| 11 | + contents: write |
| 12 | + packages: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + build-and-release: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Parse version from tag or generate timestamp |
| 22 | + run: | |
| 23 | + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then |
| 24 | + VERSION=$(date -u +%Y%m%d%H%M%S) |
| 25 | + echo "Manual trigger - using timestamp: $VERSION" |
| 26 | + else |
| 27 | + VERSION=${GITHUB_REF#refs/tags/v} |
| 28 | + echo "Tag trigger - parsed version: $VERSION" |
| 29 | + fi |
| 30 | + echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 31 | +
|
| 32 | + - name: Log in to Docker Hub |
| 33 | + uses: docker/login-action@v3 |
| 34 | + with: |
| 35 | + username: ${{ vars.DOCKERHUB_USERNAME }} |
| 36 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 37 | + |
| 38 | + - name: Set up Docker Buildx |
| 39 | + uses: docker/setup-buildx-action@v3 |
| 40 | + |
| 41 | + - name: Record Git revision |
| 42 | + run: | |
| 43 | + echo "GIT_REV=$(git rev-parse HEAD)" >> $GITHUB_ENV |
| 44 | +
|
| 45 | + - name: Build and push Docker image |
| 46 | + id: build-and-push |
| 47 | + uses: docker/build-push-action@v5 |
| 48 | + with: |
| 49 | + context: . |
| 50 | + file: docker/Dockerfile |
| 51 | + push: true |
| 52 | + tags: ${{ vars.DOCKERHUB_ORG }}/dstack-sysbox-installer:${{ env.VERSION }} |
| 53 | + platforms: linux/amd64 |
| 54 | + provenance: false |
| 55 | + build-args: | |
| 56 | + DSTACK_REV=${{ env.GIT_REV }} |
| 57 | +
|
| 58 | + - name: Generate artifact attestation |
| 59 | + uses: actions/attest-build-provenance@v1 |
| 60 | + with: |
| 61 | + subject-name: "docker.io/${{ vars.DOCKERHUB_ORG }}/dstack-sysbox-installer" |
| 62 | + subject-digest: ${{ steps.build-and-push.outputs.digest }} |
| 63 | + push-to-registry: true |
| 64 | + |
| 65 | + - name: GitHub Release |
| 66 | + uses: softprops/action-gh-release@v1 |
| 67 | + with: |
| 68 | + name: "Sysbox Installer Release v${{ env.VERSION }}" |
| 69 | + body: | |
| 70 | + ## Docker Image Information |
| 71 | +
|
| 72 | + **Image**: `docker.io/${{ vars.DOCKERHUB_ORG }}/dstack-sysbox-installer:${{ env.VERSION }}` |
| 73 | +
|
| 74 | + **Digest (SHA256)**: `${{ steps.build-and-push.outputs.digest }}` |
| 75 | +
|
| 76 | + **Verification**: [Verify on Sigstore](https://search.sigstore.dev/?hash=${{ steps.build-and-push.outputs.digest }}) |
| 77 | +
|
| 78 | + ## Installation |
| 79 | +
|
| 80 | + ```bash |
| 81 | + docker run --rm --privileged --pid=host --net=host -v /:/host \ |
| 82 | + docker.io/${{ vars.DOCKERHUB_ORG }}/dstack-sysbox-installer:${{ env.VERSION }} |
| 83 | + ``` |
| 84 | +
|
| 85 | + ## Verify Image Attestation |
| 86 | +
|
| 87 | + ```bash |
| 88 | + # Install cosign |
| 89 | + curl -O -L "https://github.com/sigstore/cosign/releases/latest/download/cosign-linux-amd64" |
| 90 | + sudo mv cosign-linux-amd64 /usr/local/bin/cosign |
| 91 | + sudo chmod +x /usr/local/bin/cosign |
| 92 | +
|
| 93 | + # Verify the image |
| 94 | + cosign verify-attestation \ |
| 95 | + --type https://slsa.dev/provenance/v1 \ |
| 96 | + --certificate-identity-regexp "^https://github.com/${{ github.repository }}/.github/workflows/release.yml@refs/tags/v${{ env.VERSION }}$" \ |
| 97 | + --certificate-oidc-issuer https://token.actions.githubusercontent.com \ |
| 98 | + docker.io/${{ vars.DOCKERHUB_ORG }}/dstack-sysbox-installer@${{ steps.build-and-push.outputs.digest }} |
| 99 | + ``` |
0 commit comments