diff --git a/.github/workflows/release-build.yaml b/.github/workflows/release-build.yaml new file mode 100644 index 0000000..1ca345a --- /dev/null +++ b/.github/workflows/release-build.yaml @@ -0,0 +1,109 @@ +# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company +# SPDX-License-Identifier: Apache-2.0 + +name: Release + +on: + release: + types: + - created + +permissions: + contents: read + packages: write + +env: + REGISTRY: ghcr.io + +jobs: + build-and-push-image: + name: Build and push container image + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Set up QEMU + uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0 + + # Set up BuildKit Docker container builder to be able to build + # multi-platform images and export cache + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 + with: + driver-opts: | + image=moby/buildkit:latest + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 + with: + images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/shoot-grafter + tags: | + type=semver,pattern={{version}},prefix=v + type=semver,pattern={{major}}.{{minor}},prefix=v + type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }},prefix=v + type=ref,event=branch + type=ref,event=tag + type=ref,event=pr + type=schedule + type=raw,value=${{ github.sha }} + type=sha,enable=true,format=short,prefix= + type=edge,branch=master + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0 + with: + context: . + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + # remove untagged images produced for multi platform builds + provenance: false + # cache-from: type=gha + # cache-to: type=gha,mode=max + platforms: | + linux/amd64 + + notify-extensions: + name: Notify greenhouse-extensions + runs-on: ubuntu-latest + needs: build-and-push-image + permissions: + contents: read + steps: + - name: Generate GitHub App token + id: app-token + uses: actions/create-github-app-token@v3 + with: + app-id: ${{ vars.APP_ID }} + private-key: ${{ secrets.APP_PRIVATE_KEY }} + repositories: greenhouse-extensions + permission-contents: write + + - name: Repository dispatch to greenhouse-extensions + uses: peter-evans/repository-dispatch@v3 + with: + token: ${{ steps.app-token.outputs.token }} + repository: abhijith-darshan/greenhouse-extensions + event-type: plugin_release + client-payload: | + { + "plugin_definition": "shoot-grafter", + "version": "${{ github.event.release.tag_name }}" + } diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..6691f6b --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company +# SPDX-License-Identifier: Apache-2.0 + +name: Release Auto + +on: + workflow_dispatch: + inputs: + version: + description: Release version (e.g. v0.3.0) + required: true + default: v0.3.0 + +permissions: + contents: write + +jobs: + create-release: + name: Create GitHub release + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Create release and generate release notes + uses: actions/github-script@v8 + with: + script: | + await github.rest.repos.createRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + tag_name: '${{ github.event.inputs.version }}', + target_commitish: context.sha, + name: '${{ github.event.inputs.version }}', + generate_release_notes: true, + draft: false, + prerelease: false + })