-
Notifications
You must be signed in to change notification settings - Fork 22
130 lines (125 loc) · 4.43 KB
/
release.yaml
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
name: Release
on:
release:
types: [published]
jobs:
publish-capi-yamls:
if: startsWith(github.ref, 'refs/tags/v') == true
runs-on: ubuntu-22.04
permissions:
id-token: write
contents: write
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- id: get_version
run: |
RELEASE_VERSION=$(echo $GITHUB_REF | sed -nE 's!refs/tags/v!!p')
echo "release_version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: false
- name: Prepare all release files for the provider
run: |
make release TAG=$RELEASE_VERSION
env:
RELEASE_VERSION: ${{ steps.get_version.outputs.release_version }}
- name: Save release assets
uses: actions/upload-artifact@v1
with:
name: release-assets
path: release/
- name: Attach assets to release
uses: FabianKramm/release-asset-action@v1
with:
pattern: "release/*"
github-token: ${{ secrets.GITHUB_TOKEN }}
publish-images:
if: startsWith(github.ref, 'refs/tags/v') == true
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- id: get_version
run: |
RELEASE_VERSION=$(echo $GITHUB_REF | sed -nE 's!refs/tags/!!p')
echo "release_version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
- name: Get Docker tags
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v2
with:
images: |
loftsh/cluster-api-provider-vcluster
tags: |
type=semver,pattern={{version}}
type=raw,value=latest
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push the image
id: docker_build
uses: docker/build-push-action@v2
with:
file: Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
- name: Images digests
run: echo ${{ steps.docker_build.outputs.digest }}
publish-release:
if: startsWith(github.ref, 'refs/tags/v') == true
needs: [publish-images]
runs-on: ubuntu-22.04
steps:
- name: Check out repo
uses: actions/checkout@v4
with:
fetch-depth: 300
- id: get_version
run: |
RELEASE_VERSION=$(echo $GITHUB_REF | sed -nE 's!refs/tags/!!p')
echo "release_version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
- uses: geertvdc/[email protected]
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
- run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- run: |
STATE=$(hub release show "$RELEASE_VERSION" --format="%S" | sed -En "s/-//p")
EXTRA_ARGS=""
if [ "$STATE" != "" ]; then
EXTRA_ARGS="$EXTRA_ARGS --$STATE"
else
EXTRA_ARGS="$EXTRA_ARGS --prerelease=false --draft=false"
fi
hub release create -m "$RELEASE_VERSION" -m "" $EXTRA_ARGS "$RELEASE_VERSION" 2>/dev/null || hub release edit -m "$RELEASE_VERSION" -m "" $EXTRA_ARGS "$RELEASE_VERSION"
env:
RELEASE_VERSION: ${{ steps.get_version.outputs.release_version }}
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
go-install-release:
# We do this in order to populate the Go proxy cache, which is used by CAPI to discover new provider releases
if: startsWith(github.ref, 'refs/tags/v') == true
needs: [publish-release]
runs-on: ubuntu-22.04
steps:
- name: Check out repo
uses: actions/checkout@v4
- id: get_version
run: |
RELEASE_VERSION=$(echo $GITHUB_REF | sed -nE 's!refs/tags/!!p')
echo "release_version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: false
- name: Run go install
run: go install github.com/loft-sh/cluster-api-provider-vcluster@"$RELEASE_VERSION"