forked from kubeedge/kubeedge
-
Notifications
You must be signed in to change notification settings - Fork 1
162 lines (156 loc) · 6.41 KB
/
release.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: build release, release image to DockerHub
on:
release:
types:
- published
env:
CONTAINER_RUN_OPTIONS: " "
IMAGE_REPOSITORY: shelleyby
jobs:
release-assests:
name: release kubeedge components
runs-on: ubuntu-22.04
strategy:
matrix:
target: [kubeedge, edgesite, keadm]
os: [linux]
ARM_VERSION: [GOARM7, GOARM8, ""]
include:
- target: kubeedge
os: windows
ARM_VERSION: ""
- target: keadm
os: windows
ARM_VERSION: ""
outputs:
hash-kubeedge-linux-amd64: ${{ steps.hash.outputs.hash-kubeedge-linux-amd64 }}
hash-kubeedge-windows-amd64: ${{ steps.hash.outputs.hash-kubeedge-windows-amd64 }}
hash-kubeedge-linux-arm64: ${{ steps.hash.outputs.hash-kubeedge-linux-arm64 }}
hash-kubeedge-linux-arm: ${{ steps.hash.outputs.hash-kubeedge-linux-arm }}
hash-keadm-linux-amd64: ${{ steps.hash.outputs.hash-keadm-linux-amd64 }}
hash-keadm-linux-arm64: ${{ steps.hash.outputs.hash-keadm-linux-arm64 }}
hash-keadm-linux-arm: ${{ steps.hash.outputs.hash-keadm-linux-arm }}
hash-keadm-windows-amd64: ${{ steps.hash.outputs.hash-keadm-windows-amd64 }}
hash-edgesite-linux-amd64: ${{ steps.hash.outputs.hash-edgesite-linux-amd64 }}
hash-edgesite-linux-arm64: ${{ steps.hash.outputs.hash-edgesite-linux-arm64 }}
hash-edgesite-linux-arm: ${{ steps.hash.outputs.hash-edgesite-linux-arm }}
steps:
- name: checkout code
uses: actions/checkout@v4
with:
# fetch-depth:
# 0 indicates all history for all branches and tags.
# for `git describe --tags` in Makefile.
fetch-depth: 0
- name: Making and packaging
run: |
if [ "${{ matrix.os }}" == "linux" ]; then
docker pull kubeedge/build-tools:1.21.11-ke1
BUILD_CONTAINER=true
else
BUILD_CONTAINER=false
fi
make release WHAT=${{ matrix.target }} ARM_VERSION=${{ matrix.ARM_VERSION }} OS=${{ matrix.os }} BUILD_WITH_CONTAINER=$BUILD_CONTAINER
- name: Generate arch
run: |
if [ "${{ matrix.ARM_VERSION }}" = "GOARM7" ]; then echo "output_arch=arm" >> $GITHUB_ENV; elif [ ${{ matrix.ARM_VERSION }} = "GOARM8" ]; then echo "output_arch=arm64" >> $GITHUB_ENV; else echo "output_arch=amd64" >> $GITHUB_ENV; fi
- name: Generate hashes
shell: bash
id: hash
run: |
cp _output/release/${{ github.ref_name }}/${{ matrix.target }}-${{ github.ref_name }}-${{ matrix.os }}-${{ env.output_arch }}.tar.gz .
echo "hash-${{ matrix.target }}-${{ matrix.os }}-${{ env.output_arch }}=$( \
sha256sum ${{ matrix.target }}-${{ github.ref_name }}-${{ matrix.os }}-${{ env.output_arch}}.tar.gz | base64 -w0 \
)" >> "$GITHUB_OUTPUT"
- name: Uploading assets...
if: ${{ !env.ACT }}
uses: softprops/action-gh-release@v1
with:
files: |
_output/release/${{ github.ref_name }}/${{ matrix.target }}-${{ github.ref_name }}-${{ matrix.os }}-${{ env.output_arch }}.tar.gz
_output/release/${{ github.ref_name }}/checksum_${{ matrix.target }}-${{ github.ref_name }}-${{ matrix.os }}-${{ env.output_arch }}.tar.gz.txt
combine_hashes:
needs: [release-assests]
runs-on: ubuntu-22.04
outputs:
hashes: ${{ steps.hashes.outputs.hashes }}
env:
HASHES: ${{ toJSON(needs.release-assests.outputs) }}
steps:
- id: hashes
run: |
echo "$HASHES" | jq -r '.[] | @base64d' | sed "/^$/d" > hashes.txt
echo "hashes=$(cat hashes.txt | base64 -w0)" >> "$GITHUB_OUTPUT"
# This step calls the generic workflow to generate provenance.
provenance:
needs: [combine_hashes]
permissions:
actions: read
id-token: write
contents: write
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
base64-subjects: "${{ needs.combine_hashes.outputs.hashes }}"
# Upload provenance to a new release
upload-assets: true
publish-image-to-dockerhub:
name: publish to DockerHub
strategy:
matrix:
target: [cloudcore]
outputs:
hash-digest-cloudcore: ${{ steps.hash.outputs.hash-digest-cloudcore }}
runs-on: ubuntu-22.04
steps:
- name: checkout code
uses: actions/checkout@v4
with:
# fetch-depth:
# 0 indicates all history for all branches and tags.
# for `git describe --tags` in Makefile.
fetch-depth: 0
- name: install QEMU
uses: docker/setup-qemu-action@v1
- name: install Buildx
uses: docker/setup-buildx-action@v1
- name: login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER_NAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: generate dockerfile path
run: |
echo "dockerfile_path=$(./hack/make-rules/imageprocess.sh dockerfile ${{ matrix.target }})" >> $GITHUB_ENV
- name: build and publish images
id: build
uses: docker/build-push-action@v3
with:
context: .
file: ${{ env.dockerfile_path }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: |
${{ env.IMAGE_REPOSITORY }}/${{ matrix.target }}:${{ github.ref_name }}
- name: generate digest
id: hash
run: |
echo "hash-digest-${{ matrix.target }}=${{ steps.build.outputs.digest }}" >> $GITHUB_OUTPUT
# This step calls the container workflow to generate provenance and push it to
# the container registry.
image-provenance:
needs: [publish-image-to-dockerhub]
strategy:
matrix:
target: [cloudcore]
permissions:
actions: read # for detecting the Github Actions environment.
id-token: write # for creating OIDC tokens for signing.
packages: write # for uploading attestations.
if: startsWith(github.ref, 'refs/tags/')
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
image: shelleyby/${{ matrix.target }}
registry-username: ${{ vars.DOCKERHUB_USER_NAME }}
digest: ${{ needs.publish-image-to-dockerhub.outputs[format('hash-digest-{0}', matrix.target)] }}
secrets:
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}