-
Notifications
You must be signed in to change notification settings - Fork 85
140 lines (116 loc) · 4.11 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
131
132
133
134
135
136
137
138
139
140
name: CI on Release Tag
# The jobs below will execute any time a tag is pushed to any branch in the repo.
on:
push:
tags:
- '*'
env:
IMAGE: rancher/system-upgrade-controller
TAG: ${{ github.ref_name }}
jobs:
# Runs e2e tests and uploads the artifact files that Dapper generates to
# GitHub Actions so we can reference them when we create the GitHub release.
build-test:
runs-on: ubuntu-latest
container: rancher/dapper:v0.6.0
permissions:
contents: read
strategy:
matrix:
os: [linux]
arch: [amd64, arm64]
steps:
- name: Add Git
run: apk add -U git
- name: Checkout code
uses: actions/checkout@v4
- name: Fix the not-a-git-repository issue
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set environment variables
run: echo "DAPPER_HOST_ARCH=${{ matrix.arch }}" >> $GITHUB_ENV
- name: Run CI
run: dapper ci
- name: Run e2e
if: ${{ matrix.arch == 'amd64' }}
run: |
dapper e2e-sonobuoy
dapper e2e-verify
- name: Generate artifact checksums
run: find dist/artifacts -type f -exec sha256sum {} \; > "dist/artifacts/sha256sum-${{ matrix.arch }}.txt"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: "artifacts-${{ matrix.os }}-${{ matrix.arch }}"
path: dist/artifacts/*
if-no-files-found: error
overwrite: true
# Creates a GitHub release using artifacts from the `build-test` job.
create-gh-release:
runs-on: ubuntu-latest
needs:
- build-test
permissions:
contents: write # needed for creating the GH release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Fix the not-a-git-repository issue
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist/artifacts
pattern: artifacts-*
merge-multiple: true
- name: Create GitHub release
run: gh release create "${{ env.TAG }}" --prerelease --title "${{ env.TAG }}" dist/artifacts/* ||
gh release upload "${{ env.TAG }}" --clobber dist/artifacts/*
# Builds Docker images using artifacts from the `build-test` job and pushes
# them to DockerHub.
build-push-images:
runs-on: ubuntu-latest
needs:
- build-test
permissions:
contents: read
id-token: write # needed for the Vault authentication
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Fix the not-a-git-repository issue
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Read secrets
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist/artifacts
pattern: artifacts-*
merge-multiple: true
- name: Build container image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: rancher/system-upgrade-controller:${{ github.event.release.tag_name }}
file: package/Dockerfile
platforms: linux/amd64, linux/arm64