-
Notifications
You must be signed in to change notification settings - Fork 225
108 lines (102 loc) · 3.19 KB
/
publish.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
name: publish
on:
push:
tags:
- '*'
jobs:
publish:
runs-on: ubuntu-latest
permissions:
actions: read
checks: write
issues: read
packages: write
pull-requests: read
repository-projects: read
statuses: read
contents: write
steps:
-
uses: actions/checkout@master
with:
fetch-depth: 1
- name: Get TAG
id: get_tag
run: echo TAG=${GITHUB_REF#refs/tags/} >> $GITHUB_ENV
-
name: Set Username/Repo and ImagePrefix as ENV vars
run: |
echo "USER_REPO"=$(echo "$GITHUB_REPOSITORY" | awk '{print tolower($1)}' | sed -e "s/:refs//") >> $GITHUB_ENV && \
echo "IMAGE_PREFIX"=$(echo "ghcr.io/$GITHUB_REPOSITORY" | awk '{print tolower($1)}' | sed -e "s/:refs//") >> $GITHUB_ENV
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Container Registry
uses: docker/login-action@v2
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
-
name: Build and Push container images (non-root)
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64
target: release
build-args: |
VERSION=${{ env.TAG }}
GIT_COMMIT=${{ github.sha }}
REPO_URL=https://github.com/${{ env.USER_REPO }}
push: true
tags: |
${{ env.IMAGE_PREFIX }}:${{ github.sha }}
${{ env.IMAGE_PREFIX }}:${{ env.TAG }}
${{ env.IMAGE_PREFIX }}:latest
-
name: Build and Push container images (root)
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64
target: root
build-args: |
VERSION=${{ env.TAG }}
GIT_COMMIT=${{ github.sha }}
REPO_URL=https://github.com/${{ env.USER_REPO }}
push: true
tags: |
${{ env.IMAGE_PREFIX }}:${{ github.sha }}-root
${{ env.IMAGE_PREFIX }}:${{ env.TAG }}-root
${{ env.IMAGE_PREFIX }}:latest-root
-
name: Build binaries for multiple environments
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile.redist
platforms: linux/amd64
build-args: |
VERSION=${{ env.TAG }}
GIT_COMMIT=${{ github.sha }}
load: true
push: false
tags: |
openfaas/faas-cli:${{ env.TAG }}
-
name: Copy binaries to host
run: ./extract_binaries.sh ${{ env.TAG }}
-
name: Create SHA of binaries
run: cd bin && ../ci/hashgen.sh && cd ../
- name: Upload binaries and their SHA to Github Release
uses: alexellis/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_paths: '["./bin/faas-cli*"]'