|
| 1 | +name: release |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - 'v*' |
| 6 | + |
| 7 | +env: |
| 8 | + CONTROLLER: image-automation-controller |
| 9 | + |
| 10 | +jobs: |
| 11 | + build-push: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v2 |
| 15 | + - name: Setup Kustomize |
| 16 | + uses: fluxcd/pkg/actions/kustomize@main |
| 17 | + - name: Prepare |
| 18 | + id: prep |
| 19 | + run: | |
| 20 | + VERSION=sha-${GITHUB_SHA::8} |
| 21 | + if [[ $GITHUB_REF == refs/tags/* ]]; then |
| 22 | + VERSION=${GITHUB_REF/refs\/tags\//} |
| 23 | + fi |
| 24 | + echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ') |
| 25 | + echo ::set-output name=VERSION::${VERSION} |
| 26 | + - name: Setup QEMU |
| 27 | + uses: docker/setup-qemu-action@v1 |
| 28 | + with: |
| 29 | + platforms: all |
| 30 | + - name: Setup Docker Buildx |
| 31 | + id: buildx |
| 32 | + uses: docker/setup-buildx-action@v1 |
| 33 | + with: |
| 34 | + buildkitd-flags: "--debug" |
| 35 | + - name: Login to GitHub Container Registry |
| 36 | + uses: docker/login-action@v1 |
| 37 | + with: |
| 38 | + registry: ghcr.io |
| 39 | + username: fluxcdbot |
| 40 | + password: ${{ secrets.GHCR_TOKEN }} |
| 41 | + - name: Login to Docker Hub |
| 42 | + uses: docker/login-action@v1 |
| 43 | + with: |
| 44 | + username: fluxcdbot |
| 45 | + password: ${{ secrets.DOCKER_FLUXCD_PASSWORD }} |
| 46 | + - name: Publish AMD64 image |
| 47 | + uses: docker/build-push-action@v2 |
| 48 | + with: |
| 49 | + push: true |
| 50 | + builder: ${{ steps.buildx.outputs.name }} |
| 51 | + context: . |
| 52 | + file: ./Dockerfile |
| 53 | + platforms: linux/amd64 |
| 54 | + tags: | |
| 55 | + ghcr.io/fluxcd/${{ env.CONTROLLER }}:${{ steps.prep.outputs.VERSION }} |
| 56 | + docker.io/fluxcd/${{ env.CONTROLLER }}:${{ steps.prep.outputs.VERSION }} |
| 57 | + labels: | |
| 58 | + org.opencontainers.image.title=${{ github.event.repository.name }} |
| 59 | + org.opencontainers.image.description=${{ github.event.repository.description }} |
| 60 | + org.opencontainers.image.url=${{ github.event.repository.html_url }} |
| 61 | + org.opencontainers.image.revision=${{ github.sha }} |
| 62 | + org.opencontainers.image.version=${{ steps.prep.outputs.VERSION }} |
| 63 | + org.opencontainers.image.created=${{ steps.prep.outputs.BUILD_DATE }} |
| 64 | + - name: Publish ARM image |
| 65 | + uses: docker/build-push-action@v2 |
| 66 | + with: |
| 67 | + push: true |
| 68 | + builder: ${{ steps.buildx.outputs.name }} |
| 69 | + context: . |
| 70 | + file: ./Dockerfile |
| 71 | + platforms: linux/arm/v7,linux/arm64 |
| 72 | + tags: | |
| 73 | + ghcr.io/fluxcd/${{ env.CONTROLLER }}-arm64:${{ steps.prep.outputs.VERSION }} |
| 74 | + labels: | |
| 75 | + org.opencontainers.image.title=${{ github.event.repository.name }} |
| 76 | + org.opencontainers.image.description=${{ github.event.repository.description }} |
| 77 | + org.opencontainers.image.url=${{ github.event.repository.html_url }} |
| 78 | + org.opencontainers.image.revision=${{ github.sha }} |
| 79 | + org.opencontainers.image.version=${{ steps.prep.outputs.VERSION }} |
| 80 | + org.opencontainers.image.created=${{ steps.prep.outputs.BUILD_DATE }} |
| 81 | + - name: Check images |
| 82 | + run: | |
| 83 | + docker buildx imagetools inspect docker.io/fluxcd/${CONTROLLER}:${{ steps.prep.outputs.VERSION }} |
| 84 | + docker buildx imagetools inspect ghcr.io/fluxcd/${CONTROLLER}:${{ steps.prep.outputs.VERSION }} |
| 85 | + docker buildx imagetools inspect ghcr.io/fluxcd/${CONTROLLER}-arm64:${{ steps.prep.outputs.VERSION }} |
| 86 | + docker pull docker.io/fluxcd/${CONTROLLER}:${{ steps.prep.outputs.VERSION }} |
| 87 | + docker pull ghcr.io/fluxcd/${CONTROLLER}:${{ steps.prep.outputs.VERSION }} |
| 88 | + - name: Generate release asset |
| 89 | + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') |
| 90 | + run: | |
| 91 | + mkdir -p config/release |
| 92 | + cp config/default/* config/release |
| 93 | + cd config/release |
| 94 | + kustomize edit set image fluxcd/${CONTROLLER}=fluxcd/${CONTROLLER}:${{ steps.get_version.outputs.VERSION }} |
| 95 | + kustomize build . > ${CONTROLLER}.yaml |
| 96 | + - name: Create release |
| 97 | + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') |
| 98 | + id: create_release |
| 99 | + uses: actions/create-release@latest |
| 100 | + env: |
| 101 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 102 | + with: |
| 103 | + tag_name: ${{ github.ref }} |
| 104 | + release_name: ${{ github.ref }} |
| 105 | + draft: false |
| 106 | + prerelease: true |
| 107 | + body: | |
| 108 | + [CHANGELOG](https://github.com/fluxcd/${{ env.CONTROLLER }}/blob/main/CHANGELOG.md) |
| 109 | + - name: Upload artifacts |
| 110 | + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') |
| 111 | + id: upload-release-asset |
| 112 | + uses: actions/upload-release-asset@v1 |
| 113 | + env: |
| 114 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 115 | + with: |
| 116 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 117 | + asset_path: ./config/release/${{ env.CONTROLLER }}.yaml |
| 118 | + asset_name: ${{ env.CONTROLLER }}.yaml |
| 119 | + asset_content_type: text/plain |
0 commit comments