-
Notifications
You must be signed in to change notification settings - Fork 97
108 lines (90 loc) · 3.7 KB
/
Copy pathrelease.yml
File metadata and controls
108 lines (90 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
# yamllint disable rule:line-length
name: publish assets after release
on: # yamllint disable-line rule:truthy
release:
types: [published] # triggers on release and pre-release
workflow_dispatch: # Useful for testing, but not necessary
permissions:
contents: write
env:
GO_VERSION: "1.25"
KUBECTL_VERSION: "1.32.2"
KUBECONFIG: /tmp/kubeconfig
jobs:
# Future - could also publish helm charts for any release (pre-release or release)
#publish-helm-charts:
attach-kubectl-volsync:
name: Build kubectl-volsync asset attach to release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm]
GOOS: [linux, darwin]
env:
GOOS: ${{ matrix.GOOS }}
steps:
- name: Checkout source
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{github.event.release.tag_name}}
# Fetch whole history so we can properly determine the version string
# (required by krew validation)
fetch-depth: 0
- name: Determine architecture
id: arch
run: |
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')"
echo "ARCH=$ARCH" >> $GITHUB_ENV
- name: Install Go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version: ${{ env.GO_VERSION }}
- name: Install kubectl
run: |
curl -fsSLO "https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/${{ env.GOOS }}/${{ env.ARCH }}/kubectl"
sudo install ./kubectl /usr/local/bin/
kubectl version --client
kubectl version --client | grep -q ${KUBECTL_VERSION}
if: ${{ env.GOOS == 'linux' }}
- name: Install krew
# https://krew.sigs.k8s.io/docs/user-guide/setup/install/
run: |
cd "$(mktemp -d)"
OS="$(uname | tr '[:upper:]' '[:lower:]')"
KREW="krew-${OS}_${{ env.ARCH }}"
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz"
tar zxvf "${KREW}.tar.gz"
./"${KREW}" install krew
echo "${KREW_ROOT:-$HOME/.krew}/bin" >> $GITHUB_PATH
if: ${{ env.GOOS == 'linux' }}
# Build & test linux versions of kubectl-volsync
- name: Test build/install of plugin via krew
run: make test-krew # Will build the plugin and output to bin/kubectl-volsync.tar.gz
if: ${{ env.GOOS == 'linux' }}
# Build (no test) darwin versions of kubectl-volsync pkged as .tar.gz
- name: Build darwin kubectl-volsync binary
run: make krew-plugin-manifest
if: ${{ env.GOOS == 'darwin' }}
- name: Attach kubectl-volsync asset to release
env:
GH_TOKEN: ${{ github.token }}
run: |
cp bin/kubectl-volsync.tar.gz bin/kubectl-volsync-${{ env.GOOS }}-${{ env.ARCH }}.tar.gz
gh release upload ${{github.event.release.tag_name}} bin/kubectl-volsync-${{ env.GOOS }}-${{ env.ARCH }}.tar.gz
publish-kubectl-volsync:
name: open PR in krew-index for kubectl-volsync
needs: [attach-kubectl-volsync]
runs-on: ubuntu-24.04
if: "!github.event.release.prerelease"
steps:
- name: Checkout source
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{github.event.release.tag_name}}
- name: Install Go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version: ${{ env.GO_VERSION }}
- name: Update new version in krew-index
uses: rajatjindal/krew-release-bot@c970b8a8f6dbc2f2285a26e3ae160903b87002c3 # v0.0.51