-
-
Notifications
You must be signed in to change notification settings - Fork 6
144 lines (139 loc) · 4.55 KB
/
pipeline.yml
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: CI Pipeline
on:
push:
paths-ignore:
- README.md
branches:
- "**"
tags-ignore:
- build-refs**
pull_request:
env:
HUB_VERSION: 2.12.7
HUB_OS: darwin
HUB_ARCH: amd64
jobs:
release-name:
name: Generate a release name to use
runs-on: ubuntu-latest
env:
HUB_OS: linux
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
if: github.event_name == 'push'
- run: echo $GITHUB_REF | sed -e 's/^refs\///g' -e 's/^tags\///g' > VERSION
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: VERSION
path: VERSION
- name: fetch hub
if: github.event_name == 'push'
run: wget -q -c https://github.com/github/hub/releases/download/v${HUB_VERSION}/hub-${HUB_OS}-${HUB_ARCH}-${HUB_VERSION}.tgz -O - | tar -xz
- name: create pre-release if it doesn't exist
if: github.event_name == 'push'
run: hub-${HUB_OS}-${HUB_ARCH}-${HUB_VERSION}/bin/hub release create -m "$(cat VERSION)" "$(cat VERSION)" || echo release already exists
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# golangci-lint:
# name: GolangCI
# runs-on: ubuntu-latest
# steps:
# - uses: actions/[email protected]
# - uses: docker://golangci/golangci-lint
# with:
# args: golangci-lint run --color=always
test-build-publish:
name: Test and Build
runs-on: macOS-latest
needs: release-name
strategy:
fail-fast: false
max-parallel: 8
matrix:
OS:
- darwin
- linux
- windows
- netbsd
- freebsd
- openbsd
- plan9
- solaris
ARCH:
- amd64
- 386
- arm64
- arm
include:
- OS: windows
EXT: .exe
exclude:
- OS: darwin
ARCH: 386
- OS: darwin
ARCH: arm
- OS: darwin
ARCH: amd64
- OS: windows
ARCH: arm64
- OS: freebsd
ARCH: arm64
- OS: plan9
ARCH: arm64
- OS: solaris
ARCH: arm64
- OS: solaris
ARCH: arm
- OS: solaris
ARCH: 386
env:
BUILD_FILENAME: kubectl-passman-${{matrix.OS}}-${{matrix.ARCH}}${{matrix.EXT}}
ZIP_FILENAME: kubectl-passman-${{matrix.OS}}-${{matrix.ARCH}}.zip
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
with:
go-version-file: './go.mod'
- run: go test -v
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: VERSION
path: VERSION
- run: go build -a -ldflags "-X main.VERSION=$(cat VERSION/VERSION)" -o ${BUILD_FILENAME}
env:
GOOS: ${{matrix.OS}}
GOARCH: ${{matrix.ARCH}}
- run: chmod +x ${BUILD_FILENAME}
env:
GOOS: ${{matrix.OS}}
GOARCH: ${{matrix.ARCH}}
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: kubectl-passman-${{matrix.OS}}-${{matrix.ARCH}}${{matrix.EXT}}
path: kubectl-passman-${{matrix.OS}}-${{matrix.ARCH}}${{matrix.EXT}}
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: VERSION
path: VERSION
- run: zip kubectl-passman-${{matrix.OS}}-${{matrix.ARCH}}.zip ${BUILD_FILENAME} LICENSE
- name: fetch hub
if: github.event_name == 'push'
run: wget -q -c https://github.com/github/hub/releases/download/v${HUB_VERSION}/hub-${HUB_OS}-${HUB_ARCH}-${HUB_VERSION}.tgz -O - | tar -xz
- name: Publish to release
if: github.event_name == 'push'
run: |
hub-${HUB_OS}-${HUB_ARCH}-${HUB_VERSION}/bin/hub release edit -a ${ZIP_FILENAME} -m "Latest build of ${{github.ref}}" "$(cat VERSION/VERSION)"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
write-krew:
name: Write krew manifest file
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
env:
HUB_OS: linux
needs:
- test-build-publish
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Update new version in krew-index
uses: rajatjindal/krew-release-bot@df3eb197549e3568be8b4767eec31c5e8e8e6ad8 # v0.0.46