|
| 1 | +name: release |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - 'v*' |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + tag: |
| 9 | + description: 'image tag prefix' |
| 10 | + default: 'rc' |
| 11 | + required: true |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: write # needed to write releases |
| 15 | + id-token: write # needed for keyless signing |
| 16 | + packages: write # needed for ghcr access |
| 17 | + |
| 18 | +env: |
| 19 | + CONTROLLER: ${{ github.event.repository.name }} |
| 20 | + |
| 21 | +jobs: |
| 22 | + build-push: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v2 |
| 26 | + - name: Setup Kustomize |
| 27 | + uses: fluxcd/pkg/actions/kustomize@main |
| 28 | + - name: Prepare |
| 29 | + id: prep |
| 30 | + run: | |
| 31 | + VERSION="${{ github.event.inputs.tag }}-${GITHUB_SHA::8}" |
| 32 | + if [[ $GITHUB_REF == refs/tags/* ]]; then |
| 33 | + VERSION=${GITHUB_REF/refs\/tags\//} |
| 34 | + fi |
| 35 | + echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ') |
| 36 | + echo ::set-output name=VERSION::${VERSION} |
| 37 | + - name: Setup QEMU |
| 38 | + uses: docker/setup-qemu-action@v1 |
| 39 | + with: |
| 40 | + platforms: all |
| 41 | + - name: Setup Docker Buildx |
| 42 | + id: buildx |
| 43 | + uses: docker/setup-buildx-action@v1 |
| 44 | + with: |
| 45 | + buildkitd-flags: "--debug" |
| 46 | + - name: Login to GitHub Container Registry |
| 47 | + uses: docker/login-action@v1 |
| 48 | + with: |
| 49 | + registry: ghcr.io |
| 50 | + username: ${{ github.actor }} |
| 51 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + - name: Generate images meta |
| 53 | + id: meta |
| 54 | + uses: docker/metadata-action@v3 |
| 55 | + with: |
| 56 | + images: | |
| 57 | + ghcr.io/doodlescheduling/${{ env.CONTROLLER }} |
| 58 | + tags: | |
| 59 | + type=raw,value=${{ steps.prep.outputs.VERSION }} |
| 60 | + - name: Publish multi-arch container image |
| 61 | + uses: docker/build-push-action@v2 |
| 62 | + with: |
| 63 | + push: true |
| 64 | + builder: ${{ steps.buildx.outputs.name }} |
| 65 | + context: . |
| 66 | + file: ./Dockerfile |
| 67 | + platforms: linux/amd64,linux/arm/v7,linux/arm64 |
| 68 | + tags: ${{ steps.meta.outputs.tags }} |
| 69 | + labels: ${{ steps.meta.outputs.labels }} |
| 70 | + - name: Check images |
| 71 | + run: | |
| 72 | + docker buildx imagetools inspect ghcr.io/doodlescheduling/${{ env.CONTROLLER }}:${{ steps.prep.outputs.VERSION }} |
| 73 | + docker pull ghcr.io/doodlescheduling/${{ env.CONTROLLER }}:${{ steps.prep.outputs.VERSION }} |
| 74 | + - name: Generate release manifests |
| 75 | + if: startsWith(github.ref, 'refs/tags/v') |
| 76 | + run: | |
| 77 | + mkdir -p config/release |
| 78 | + kustomize build ./config/crd > ./config/release/${{ env.CONTROLLER }}.crds.yaml |
| 79 | + kustomize build ./config/manager > ./config/release/${{ env.CONTROLLER }}.deployment.yaml |
| 80 | + echo '[CHANGELOG](https://github.com/DoodleScheduling/${{ env.CONTROLLER }}/blob/master/CHANGELOG.md)' > ./config/release/notes.md |
| 81 | + - uses: anchore/sbom-action/download-syft@v0 |
| 82 | + - name: Create release and SBOM |
| 83 | + if: startsWith(github.ref, 'refs/tags/v') |
| 84 | + uses: goreleaser/goreleaser-action@v2 |
| 85 | + with: |
| 86 | + version: latest |
| 87 | + args: release --release-notes=config/release/notes.md --rm-dist --skip-validate |
| 88 | + env: |
| 89 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments