-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (152 loc) · 5.23 KB
/
Copy pathbuild.yaml
File metadata and controls
154 lines (152 loc) · 5.23 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
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
name: Build
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: go.mod
- uses: actions/cache/restore@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
with:
path: ~/.local/share/aquaproj-aqua
key: v1-aqua-installer-${{runner.os}}-${{runner.arch}}-${{hashFiles('aqua.yaml')}}
restore-keys: |
v1-aqua-installer-${{runner.os}}-${{runner.arch}}-
- uses: aquaproj/aqua-installer@11dd79b4e498d471a9385aa9fb7f62bb5f52a73c # v4.0.4
with:
aqua_version: v2.46.0
- name: Run unit tests
run: |
make test
- name: Build all
run: |
make all
make archive
- name: Run e2e tests
run: |
aqua i
make test-e2e
- name: upload e2e test logs
if: failure()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
path: e2e/logs
- name: upload build artifacts
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: build
path: build.tar
- uses: actions/cache/save@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
if: github.event_name == 'push'
with:
path: ~/.local/share/aquaproj-aqua
key: v1-aqua-installer-${{runner.os}}-${{runner.arch}}-${{hashFiles('aqua.yaml')}}
build-image:
runs-on: ubuntu-latest
needs: [test]
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Download artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: build
- name: Extract artifacts
run: |
tar -xf build.tar
rm -f build.tar
- name: Get photon version
id: photon_metadata
run: |
source .env
echo "version=${PHOTON_VERSION}" >> $GITHUB_OUTPUT
echo "sha256=${PHOTON_SHA256SUM}" >> $GITHUB_OUTPUT
echo "revision=${CONTAINER_REVISION}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Login to ghcr.io
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine image tags
id: tags
run: |
IMAGE=ghcr.io/pddg/photon
TAG="${{ steps.photon_metadata.outputs.version }}-rev.${{ steps.photon_metadata.outputs.revision }}"
if docker manifest inspect $IMAGE:$TAG > /dev/null 2>&1; then
echo "Tag $TAG already exists, skipping"
TAGS="latest"
else
echo "$TAG does not exist. It will be created."
TAGS="$TAG latest"
fi
echo "tags<<EOF" >> $GITHUB_OUTPUT
for t in $TAGS; do
echo $IMAGE:$t >> $GITHUB_OUTPUT
done
echo "EOF" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
build-args: |
PHOTON_VERSION=${{ steps.photon_metadata.outputs.version }}
PHOTON_SHA256SUM=${{ steps.photon_metadata.outputs.sha256 }}
GIT_SHA=${{ github.sha }}
tags: |
${{ steps.tags.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
release:
if: github.event_name == 'push'
runs-on: ubuntu-latest
needs: [build-image]
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: build
- name: Extract artifacts
run: |
tar -xf build.tar
rm -f build.tar
- name: create checksum file
run: |
sha256sum build/* > ./checksum.txt
mv ./checksum.txt build/
- name: create release if needs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
source .env
TAG="${PHOTON_VERSION}-rev.${CONTAINER_REVISION}"
if [ ! -z "$(git tag -l $TAG)" ]; then
echo "Tag $TAG already exists, skipping"
exit 0
fi
echo "Tag $TAG does not exist. It will be created."
gh release create $TAG \
--title "$TAG" \
--generate-notes \
build/*