From 713c46097ffa0a2086ad312d3abb36f23154c9e9 Mon Sep 17 00:00:00 2001 From: pyadagiri Date: Tue, 15 Sep 2026 21:10:58 +0530 Subject: [PATCH 1/3] Automate do-operator release manifests in GHA --- .github/workflows/release.yml | 40 +++++++++++++++++++++++++++-------- Makefile | 3 +++ README.md | 17 +++++++++------ 3 files changed, 45 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c62ffae0..7aef5ef3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,12 @@ name: release on: - push: - tags: - - v** + workflow_dispatch: + inputs: + tag: + description: 'tag and release to create (e.g. v0.1.17)' + required: true +permissions: + contents: write env: GITHUB_ENV: ".env" jobs: @@ -15,13 +19,31 @@ jobs: go-version: ^1.27 - name: Check out code into the Go module directory uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Validate that the release manifest exists - run: | - [[ -f "releases/do-operator-$(git describe --tags).yaml" ]] || false - name: Login to dockerhub to push the image - run: echo "${{ secrets.DockerHubToken }}" | docker login --username ${DOCKER_USER} --password-stdin + run: echo "${{ secrets.DockerHubToken }}" | docker login --username "${DOCKER_USER}" --password-stdin env: DOCKER_USER: ${{ secrets.DockerHubUser }} - - name: Build and push docker image + - name: Build image, push, and generate release manifests + run: make release + env: + IMG_TAG: ${{ github.event.inputs.tag }} + - name: Commit release manifests + uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 + with: + message: "create release manifests for ${{ github.event.inputs.tag }}" + add: "releases/ config/manager/kustomization.yaml" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: find target commit to tag run: | - make docker-build docker-push IMG_TAG="$(git describe --tags)" + sha="$(git rev-parse HEAD)" + echo "TARGET_SHA=${sha}" >> "${GITHUB_ENV}" + - name: Create Release + id: create_release + uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + commitish: ${{ env.TARGET_SHA }} + tag_name: ${{ github.event.inputs.tag }} + release_name: Release ${{ github.event.inputs.tag }} diff --git a/Makefile b/Makefile index ac9e1a2b..48409aca 100644 --- a/Makefile +++ b/Makefile @@ -113,6 +113,9 @@ release-manifests: manifests kustomize # replace the fake do api token cause GitGuardian thinks every base64-encoded string is a secret sed -i -e 's/access-token\:\s.*/access-token: /g' releases/do-operator-${IMG_TAG}.yaml +.PHONY: release +release: docker-build docker-push release-manifests ## Build/push image and generate release manifests for IMG_TAG + ##@ Build Dependencies ## Location to install dependencies to diff --git a/README.md b/README.md index c6814c93..e1ca3bd7 100644 --- a/README.md +++ b/README.md @@ -130,12 +130,17 @@ make uninstall 4. Create and merge PR ### Release -1. Create release manifest files by running `GITHUB_TOKEN= IMG_TAG=vX.Y.Z make release-manifests` -2. Create and merge PR -3. [Trigger the `release` GitHub action workflow](https://github.com/digitalocean/do-operator/actions/workflows/release.yml) - - Draft a new release [here](https://github.com/digitalocean/do-operator/releases) for the new version - - Creating a new release will trigger the [release](https://github.com/digitalocean/do-operator/actions/workflows/release.yml) Github Action - - Follow the [release](https://github.com/digitalocean/do-operator/actions/workflows/release.yml) Github Action until successful completion. +To build/push the image, generate release manifests, commit them, and create the GitHub release/tag, go to the actions page and click **Run workflow** on [`release`](https://github.com/digitalocean/do-operator/actions/workflows/release.yml). Provide the tag (e.g. `v0.1.17`). + +Running the workflow requires temporarily turning off "Require a pull request before merging" in the [main branch protection rules](https://github.com/digitalocean/do-operator/settings/branches) so the workflow can commit the generated manifests. Turn it back on once the release finishes. + +The workflow does the following: + +- Logs in to Docker Hub with credentials from secrets +- Builds and pushes `digitalocean/do-operator:` +- Generates `releases/do-operator-.yaml` and updates `config/manager/kustomization.yaml` +- Commits those files to `main` +- Creates a GitHub release and tag for the input `tag` ## Contributing From 4bd77898872d2c638c10d74239ee0103967776ee Mon Sep 17 00:00:00 2001 From: pyadagiri Date: Tue, 15 Sep 2026 21:24:16 +0530 Subject: [PATCH 2/3] Align release workflow style with dosecret-operator --- .github/workflows/release.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7aef5ef3..867a184f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,12 +1,13 @@ name: release on: workflow_dispatch: + # Inputs the workflow accepts. inputs: tag: - description: 'tag and release to create (e.g. v0.1.17)' + # Friendly description to be shown in the UI instead of 'name' + description: 'tag and release to create' + # Input has to be provided for the workflow to run required: true -permissions: - contents: write env: GITHUB_ENV: ".env" jobs: @@ -23,17 +24,19 @@ jobs: run: echo "${{ secrets.DockerHubToken }}" | docker login --username "${DOCKER_USER}" --password-stdin env: DOCKER_USER: ${{ secrets.DockerHubUser }} - - name: Build image, push, and generate release manifests + - name: run make release ${{ github.event.inputs.tag }} run: make release env: IMG_TAG: ${{ github.event.inputs.tag }} - - name: Commit release manifests + - name: commit manifests uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 with: message: "create release manifests for ${{ github.event.inputs.tag }}" + # Also pin the controller image tag in config/manager (release-manifests runs kustomize edit). add: "releases/ config/manager/kustomization.yaml" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # target commit should be the commit with the new release manifest, not the commit when workflow was triggered - name: find target commit to tag run: | sha="$(git rev-parse HEAD)" From 08120f87ab31e12e3cfcbb721afac540101b98ac Mon Sep 17 00:00:00 2001 From: pyadagiri Date: Tue, 15 Sep 2026 21:26:41 +0530 Subject: [PATCH 3/3] readme update --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e1ca3bd7..d50b9388 100644 --- a/README.md +++ b/README.md @@ -130,17 +130,19 @@ make uninstall 4. Create and merge PR ### Release -To build/push the image, generate release manifests, commit them, and create the GitHub release/tag, go to the actions page and click **Run workflow** on [`release`](https://github.com/digitalocean/do-operator/actions/workflows/release.yml). Provide the tag (e.g. `v0.1.17`). -Running the workflow requires temporarily turning off "Require a pull request before merging" in the [main branch protection rules](https://github.com/digitalocean/do-operator/settings/branches) so the workflow can commit the generated manifests. Turn it back on once the release finishes. +To create the docker image and generate the manifests, go to the actions page on Github and click on `Run Workflow` . +Specify the github tag that you want to create. Running the workflow also requires that you temporarily turn off "Require a pull request before merging" setting in the main [branch protection rules settings](https://github.com/digitalocean/do-operator/settings/branches). Don't forget to turn it back on once the release is done! The workflow does the following: -- Logs in to Docker Hub with credentials from secrets -- Builds and pushes `digitalocean/do-operator:` -- Generates `releases/do-operator-.yaml` and updates `config/manager/kustomization.yaml` -- Commits those files to `main` -- Creates a GitHub release and tag for the input `tag` +- Login with dockerhub credentials specified as secrets +- Builds the docker image `digitalocean/do-operator:` +- Pushes `digitalocean/do-operator:` to dockerhub +- Creates the do-operator related manifest file as `do-operator-.yaml` +- Updates `config/manager/kustomization.yaml` with the release image tag +- Commits the manifest file under releases/ directory in the repo +- Creates release and tags the new commit with the input `tag` specified when workflow is triggered ## Contributing