Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 34 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: release
on:
push:
tags:
- v**
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
tag:
# 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
env:
GITHUB_ENV: ".env"
jobs:
Expand All @@ -15,13 +20,33 @@ 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: run make release ${{ github.event.inputs.tag }}
run: make release
env:
IMG_TAG: ${{ github.event.inputs.tag }}
- 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: |
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 }}
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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: <your api token here>/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
Expand Down
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,19 @@ make uninstall
4. Create and merge PR

### Release
1. Create release manifest files by running `GITHUB_TOKEN=<redacted> 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 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:

- Login with dockerhub credentials specified as secrets
- Builds the docker image `digitalocean/do-operator:<tag>`
- Pushes `digitalocean/do-operator:<tag>` to dockerhub
- Creates the do-operator related manifest file as `do-operator-<tag>.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

Expand Down
Loading