Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update release and ci jobs #656

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
41 changes: 36 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,72 @@ env:
jobs:
release:
runs-on: ubuntu-latest

permissions:
contents: read
id-token: write

steps:

- name: Check out code into the Go module directory
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
ref: master

- name: Install go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: go.mod
check-latest: true

- name: Install cosign
uses: sigstore/cosign-installer@11086d25041f77fe8fe7b9ea4e48e3b9192b8f19 # v3.1.2

- name: Install crane
uses: uses: imjasonh/setup-crane@00c9e93efa4e1138c9a7a5c594acd6c75a2fbf0c # v0.3

- name: Login to dockerhub to push the image
run: echo "${{ secrets.DockerHubToken }}" | docker login --username ${DOCKER_USER} --password-stdin
env:
DOCKER_USER: ${{ secrets.DockerHubUser }}

- name: Login to DockerHub
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
username: ${{ secrets.DockerHubUser }}
password: ${{ secrets.DockerHubToken }}

- name: Publish Docker Image
env:
VERSION: ${{ github.event.inputs.tag }}
run: make ci publish

- name: Sign Image and copy to ghcr.io
env:
VERSION: ${{ github.event.inputs.tag }}
run: make sign

- name: run make bump-version
run: make bump-version
env:
NEW_VERSION: ${{ github.event.inputs.tag }}

- name: commit manifests
uses: EndBug/add-and-commit@1bad3abcf0d6ec49a5857d124b0bfb52dc7bb081
uses: EndBug/add-and-commit@1bad3abcf0d6ec49a5857d124b0bfb52dc7bb081 # v9.1.3
with:
message: "create release manifests for ${{ github.event.inputs.tag }}"
add: "releases/ VERSION CHANGELOG.md"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# target commit should be the commit with the new release manifest, not the commit when workflow was triggered

# 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)
echo "TARGET_SHA=$sha" >> $GITHUB_ENV

- name: Create GitHub Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
28 changes: 19 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
fetch-depth: 1

- name: Install go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: go.mod
check-latest: true

- name: Run tests
run: make ci
Expand All @@ -27,23 +29,31 @@ jobs:

release-dev-image:
runs-on: ubuntu-latest

permissions:
contents: read
id-token: write

needs: test
if: github.ref == 'refs/heads/master'
steps:
- name: checkout
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
fetch-depth: 1

- name: Install go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: go.mod
check-latest: true

- name: Login to DockerHub
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
username: ${{ secrets.DockerHubUser }}
password: ${{ secrets.DockerHubToken }}

- name: Login to dockerhub to push the image
run: echo "${{ secrets.DockerHubToken }}" | docker login --username ${DOCKER_USER} --password-stdin
env:
DOCKER_USER: ${{ secrets.DockerHubUser }}
- name: build and push new CCM dev image
run: |
VERSION=dev make publish
VERSION=dev make publish sign
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COMMIT ?= $(shell git rev-parse HEAD)
BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
VERSION ?= $(shell cat VERSION)
REGISTRY ?= digitalocean
REGISTRY_GHCR ?= ghcr.io/digitalocean
GO_VERSION ?= $(shell go mod edit -print | grep -E '^go [[:digit:].]*' | cut -d' ' -f2)

LDFLAGS ?= -X github.com/digitalocean/digitalocean-cloud-controller-manager/cloud-controller-manager/do.version=$(VERSION) -X github.com/digitalocean/digitalocean-cloud-controller-manager/vendor/k8s.io/kubernetes/pkg/version.gitVersion=$(VERSION) -X github.com/digitalocean/digitalocean-cloud-controller-manager/vendor/k8s.io/kubernetes/pkg/version.gitCommit=$(COMMIT) -X github.com/digitalocean/digitalocean-cloud-controller-manager/vendor/k8s.io/kubernetes/pkg/version.gitTreeState=$(GIT_TREE_STATE)
Expand Down Expand Up @@ -89,6 +90,9 @@ else
@echo "==> Your image is now available at $(REGISTRY)/digitalocean-cloud-controller-manager:$(VERSION)"
endif

sign:
@cosign sign --yes $(REGISTRY)/digitalocean-cloud-controller-manager@$(shell crane digest $(REGISTRY)/digitalocean-cloud-controller-manager:$(VERSION))

.PHONY: govet
govet:
@go vet $(shell go list ./... | grep -v vendor)
Expand Down