|
| 1 | +name: Build Bowtie Image for all available versions |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +env: |
| 7 | + IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} |
| 8 | + |
| 9 | +jobs: |
| 10 | + versions: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: |
| 13 | + revisions: ${{ steps.revisions.outputs.value }} |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + fetch-depth: 0 |
| 18 | + fetch-tags: true |
| 19 | + - name: Collect available versions |
| 20 | + id: revisions |
| 21 | + run: | |
| 22 | + tags=$(jq -c -n '$ARGS.positional + ["main"]' --args $(git tag --list)) |
| 23 | + echo "value=$(echo $tags | jq -c .)" >> $GITHUB_OUTPUT |
| 24 | +
|
| 25 | + build: |
| 26 | + needs: versions |
| 27 | + runs-on: ubuntu-latest |
| 28 | + strategy: |
| 29 | + fail-fast: true |
| 30 | + matrix: |
| 31 | + revision: ${{ fromJson(needs.versions.outputs.revisions) }} |
| 32 | + permissions: |
| 33 | + id-token: write |
| 34 | + contents: read |
| 35 | + attestations: write |
| 36 | + packages: write |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v4 |
| 39 | + with: |
| 40 | + ref: ${{ matrix.revision }} |
| 41 | + |
| 42 | + - name: Compute implementation name |
| 43 | + id: impl |
| 44 | + run: echo "name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_OUTPUT |
| 45 | + |
| 46 | + - name: Install bowtie |
| 47 | + uses: bowtie-json-schema/bowtie@main |
| 48 | + |
| 49 | + - name: Build |
| 50 | + id: build_image |
| 51 | + uses: redhat-actions/buildah-build@v2 |
| 52 | + with: |
| 53 | + context: '.' |
| 54 | + containerfiles: | |
| 55 | + Dockerfile |
| 56 | + image: ${{ steps.impl.outputs.name }} |
| 57 | + tags: ${{ github.sha }} ${{ matrix.revision == 'main' && 'latest' || '' }} |
| 58 | + archs: amd64, arm64 |
| 59 | + |
| 60 | + - name: Set DOCKER_HOST so podman-built images are findable |
| 61 | + run: | |
| 62 | + systemctl --user enable --now podman.socket |
| 63 | + sudo loginctl enable-linger $USER |
| 64 | + podman --remote info |
| 65 | + echo "DOCKER_HOST=unix://$(podman info --format '{{.Host.RemoteSocket.Path}}')" >> $GITHUB_ENV |
| 66 | +
|
| 67 | + - name: Smoke Test |
| 68 | + run: | |
| 69 | + bowtie smoke -i "localhost/${{ steps.build_image.outputs.image-with-tag }}" --format json |
| 70 | + bowtie smoke -i "localhost/${{ steps.build_image.outputs.image-with-tag }}" --format markdown >> $GITHUB_STEP_SUMMARY |
| 71 | +
|
| 72 | + - name: Collect current version |
| 73 | + id: current-version |
| 74 | + run: | |
| 75 | + version=$(bowtie info \ |
| 76 | + --implementation "localhost/${{ steps.build_image.outputs.image-with-tag }}" \ |
| 77 | + --format json | jq -r '.version // empty') |
| 78 | + echo "value=${version}" >> $GITHUB_OUTPUT |
| 79 | +
|
| 80 | + - name: Print collected version |
| 81 | + run: echo "current_version=${{ steps.current-version.outputs.value }}" |
| 82 | + |
| 83 | + - name: Log in to ghcr.io |
| 84 | + uses: redhat-actions/podman-login@v1 |
| 85 | + with: |
| 86 | + username: ${{ github.actor }} |
| 87 | + password: ${{ github.token }} |
| 88 | + registry: ${{ env.IMAGE_REGISTRY }} |
| 89 | + |
| 90 | + - name: Add tag with version to the image |
| 91 | + run: podman tag ${{ steps.build_image.outputs.image-with-tag }} ${{ steps.build_image.outputs.image }}:${{ steps.current-version.outputs.value }} |
| 92 | + |
| 93 | + - name: Publish |
| 94 | + id: push |
| 95 | + uses: redhat-actions/push-to-registry@v2 |
| 96 | + with: |
| 97 | + image: ${{ steps.build_image.outputs.image }} |
| 98 | + tags: ${{ steps.current-version.outputs.value }} ${{ steps.build_image.outputs.tags }} |
| 99 | + registry: ${{ env.IMAGE_REGISTRY }} |
| 100 | + |
| 101 | + - name: Generate attestation for images |
| 102 | + uses: actions/attest-build-provenance@v2 |
| 103 | + with: |
| 104 | + subject-name: ${{ env.IMAGE_REGISTRY }}/${{ steps.build_image.outputs.image }} |
| 105 | + subject-digest: ${{ steps.push.outputs.digest }} |
| 106 | + push-to-registry: true |
0 commit comments