Skip to content

Commit 2aeaa9b

Browse files
committed
makefile-modules: migrate the Makefile to makefile-modules
Initially, my goal was to just renamed the Makefile to make/02_mod.mk, and change nothing else, with the intent of migrating bit by bit. After a few attempts, I found that the fact that the Makefile is being run within a container makes things needlessly complex, and trying to make makefile-modules work in that context isn't worth it. That's why I propose to migrate everything at once, with the goal of making no breaking changes to the Helm charts and containers (except for the binary location, binary name, entrypoint, and cmd).
1 parent 5750c18 commit 2aeaa9b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+3859
-343
lines changed

.github/dependabot.yaml

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1+
# THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
2+
# Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/repository-base/base/.github/dependabot.yaml instead.
3+
4+
# Update Go dependencies and GitHub Actions dependencies daily.
15
version: 2
26
updates:
3-
- package-ecosystem: gomod
4-
directory: /
5-
schedule:
6-
interval: daily
7-
groups:
8-
all:
9-
patterns: ["*"]
10-
- package-ecosystem: github-actions
11-
directory: /
12-
schedule:
13-
interval: daily
14-
groups:
15-
all:
16-
patterns: ["*"]
17-
- package-ecosystem: docker
18-
directory: /
19-
schedule:
20-
interval: daily
21-
groups:
22-
all:
23-
patterns: ["*"]
7+
- package-ecosystem: gomod
8+
directory: /
9+
schedule:
10+
interval: daily
11+
groups:
12+
all:
13+
patterns: ["*"]
14+
- package-ecosystem: github-actions
15+
directory: /
16+
schedule:
17+
interval: daily
18+
groups:
19+
all:
20+
patterns: ["*"]
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
2+
# Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/repository-base/base/.github/workflows/make-self-upgrade.yaml instead.
3+
4+
name: make-self-upgrade
5+
concurrency: make-self-upgrade
6+
on:
7+
workflow_dispatch: {}
8+
schedule:
9+
- cron: '0 0 * * *'
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
self_upgrade:
16+
runs-on: ubuntu-latest
17+
18+
permissions:
19+
contents: write
20+
pull-requests: write
21+
22+
env:
23+
SOURCE_BRANCH: "${{ github.ref_name }}"
24+
SELF_UPGRADE_BRANCH: "self-upgrade-${{ github.ref_name }}"
25+
26+
steps:
27+
- name: Fail if branch is not head of branch.
28+
if: ${{ !startsWith(github.ref, 'refs/heads/') && env.SOURCE_BRANCH != '' && env.SELF_UPGRADE_BRANCH != '' }}
29+
run: |
30+
echo "This workflow should not be run on a non-branch-head."
31+
exit 1
32+
33+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
34+
35+
- id: go-version
36+
run: |
37+
make print-go-version >> "$GITHUB_OUTPUT"
38+
39+
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
40+
with:
41+
go-version: ${{ steps.go-version.outputs.result }}
42+
43+
- run: |
44+
git checkout -B "$SELF_UPGRADE_BRANCH"
45+
46+
- run: |
47+
make -j upgrade-klone
48+
make -j generate
49+
50+
- id: is-up-to-date
51+
shell: bash
52+
run: |
53+
git_status=$(git status -s)
54+
is_up_to_date="true"
55+
if [ -n "$git_status" ]; then
56+
is_up_to_date="false"
57+
echo "The following changes will be committed:"
58+
echo "$git_status"
59+
fi
60+
echo "result=$is_up_to_date" >> "$GITHUB_OUTPUT"
61+
62+
- if: ${{ steps.is-up-to-date.outputs.result != 'true' }}
63+
run: |
64+
git config --global user.name "cert-manager-bot"
65+
git config --global user.email "[email protected]"
66+
git add -A && git commit -m "BOT: run 'make upgrade-klone' and 'make generate'" --signoff
67+
git push -f origin "$SELF_UPGRADE_BRANCH"
68+
69+
- if: ${{ steps.is-up-to-date.outputs.result != 'true' }}
70+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
71+
with:
72+
script: |
73+
const { repo, owner } = context.repo;
74+
const pulls = await github.rest.pulls.list({
75+
owner: owner,
76+
repo: repo,
77+
head: owner + ':' + process.env.SELF_UPGRADE_BRANCH,
78+
base: process.env.SOURCE_BRANCH,
79+
state: 'open',
80+
});
81+
82+
if (pulls.data.length < 1) {
83+
const result = await github.rest.pulls.create({
84+
title: '[CI] Merge ' + process.env.SELF_UPGRADE_BRANCH + ' into ' + process.env.SOURCE_BRANCH,
85+
owner: owner,
86+
repo: repo,
87+
head: process.env.SELF_UPGRADE_BRANCH,
88+
base: process.env.SOURCE_BRANCH,
89+
body: [
90+
'This PR is auto-generated to bump the Makefile modules.',
91+
].join('\n'),
92+
});
93+
await github.rest.issues.addLabels({
94+
owner,
95+
repo,
96+
issue_number: result.data.number,
97+
labels: ['skip-review']
98+
});
99+
}

.github/workflows/release.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
name: release
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
env:
9+
VERSION: ${{ github.ref_name }}
10+
11+
jobs:
12+
build_images:
13+
runs-on: ubuntu-latest
14+
15+
permissions:
16+
contents: read # needed for checkout
17+
packages: write # needed for push images
18+
id-token: write # needed for keyless signing
19+
20+
env:
21+
GOPRIVATE: github.com/jetstack/venafi-connection-lib
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- id: go-version
27+
run: |
28+
make print-go-version >> "$GITHUB_OUTPUT"
29+
30+
- uses: actions/setup-go@v5
31+
with:
32+
go-version: ${{ steps.go-version.outputs.result }}
33+
34+
- name: Configure jetstack/venafi-connection-lib repo pull access
35+
run: |
36+
mkdir ~/.ssh
37+
chmod 700 ~/.ssh
38+
39+
echo "${{ secrets.DEPLOY_KEY_READ_VENAFI_CONNECTION_LIB }}" > ~/.ssh/venafi_connection_lib_id
40+
chmod 600 ~/.ssh/venafi_connection_lib_id
41+
42+
cat <<EOT >> ~/.ssh/config
43+
Host venafi-connection-lib.github.com
44+
HostName github.com
45+
IdentityFile ~/.ssh/venafi_connection_lib_id
46+
IdentitiesOnly yes
47+
EOT
48+
49+
cat <<EOT >> ~/.gitconfig
50+
[url "[email protected]:jetstack/venafi-connection-lib"]
51+
insteadOf = https://github.com/jetstack/venafi-connection-lib
52+
EOT
53+
54+
- uses: actions/cache@v4
55+
with:
56+
path: _bin/downloaded
57+
key: downloaded-${{ runner.os }}-${{ hashFiles('make/_shared/tools/00_mod.mk') }}-${{ hashFiles('make/_shared/kind/00_kind_image_versions.mk') }}
58+
59+
- id: release
60+
run: make release
61+
62+
- uses: actions/upload-artifact@v4
63+
with:
64+
name: ${{ steps.release.outputs.RELEASE_HELM_CHART_NAME }}-${{ steps.release.outputs.RELEASE_HELM_CHART_VERSION }}.tgz
65+
path: ${{ steps.release.outputs.RELEASE_HELM_CHART_TAR }}
66+
if-no-files-found: error
67+
68+
outputs:
69+
RELEASE_OCI_PREFLIGHT_IMAGE: ${{ steps.release.outputs.RELEASE_OCI_PREFLIGHT_IMAGE }}
70+
RELEASE_OCI_PREFLIGHT_TAG: ${{ steps.release.outputs.RELEASE_OCI_PREFLIGHT_TAG }}
71+
RELEASE_HELM_CHART_NAME: ${{ steps.release.outputs.RELEASE_HELM_CHART_NAME }}
72+
RELEASE_HELM_CHART_VERSION: ${{ steps.release.outputs.RELEASE_HELM_CHART_VERSION }}
73+
74+
github_release:
75+
runs-on: ubuntu-latest
76+
77+
needs: build_images
78+
79+
permissions:
80+
contents: write # needed for creating a PR
81+
pull-requests: write # needed for creating a PR
82+
83+
steps:
84+
- run: |
85+
touch .notes-file
86+
echo "OCI_PREFLIGHT_IMAGE: ${{ needs.build_images.outputs.RELEASE_OCI_PREFLIGHT_IMAGE }}" >> .notes-file
87+
echo "OCI_PREFLIGHT_TAG: ${{ needs.build_images.outputs.RELEASE_OCI_PREFLIGHT_TAG }}" >> .notes-file
88+
echo "HELM_CHART_NAME: ${{ needs.build_images.outputs.RELEASE_HELM_CHART_NAME }}" >> .notes-file
89+
echo "HELM_CHART_VERSION: ${{ needs.build_images.outputs.RELEASE_HELM_CHART_VERSION }}" >> .notes-file
90+
91+
- id: chart_download
92+
uses: actions/download-artifact@v4
93+
with:
94+
name: ${{ needs.build_images.outputs.RELEASE_HELM_CHART_NAME }}-${{ needs.build_images.outputs.RELEASE_HELM_CHART_VERSION }}.tgz
95+
96+
- env:
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98+
run: |
99+
gh release create "$VERSION" \
100+
--repo="$GITHUB_REPOSITORY" \
101+
--title="${VERSION}" \
102+
--draft \
103+
--verify-tag \
104+
--notes-file .notes-file
105+
106+
gh release upload "$VERSION" \
107+
--repo="$GITHUB_REPOSITORY" \
108+
"${{ steps.chart_download.outputs.download-path }}/${{ needs.build_images.outputs.RELEASE_HELM_CHART_NAME }}-${{ needs.build_images.outputs.RELEASE_HELM_CHART_VERSION }}.tgz"

0 commit comments

Comments
 (0)