-
Notifications
You must be signed in to change notification settings - Fork 6
90 lines (88 loc) · 3.48 KB
/
service.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
#
# Copyright (c) 2023 - for information on the respective copyright owner
# see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.
#
# SPDX-License-Identifier: Apache-2.0
#
name: Publish Service
on:
push:
tags:
- "service-v[0-9]+.[0-9]+.[0-9]+"
env:
REGISTRY: ghcr.io
IMAGE_NAME: carbynestack/ephemeral
jobs:
publish:
runs-on: ubuntu-22.04
env:
GOPATH: ${{ github.workspace }}
GO111MODULE: on
WORKING_DIRECTORY: ${{ github.workspace }}/src/github.com/${{ github.repository }}
defaults:
run:
working-directory: ${{ env.WORKING_DIRECTORY }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
path: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}
- name: Retrieve license obligation resources
run: |
cd 3RD-PARTY-LICENSES
find . -maxdepth 1 -type d -not -path . | zip -r@ 3rd-party-copyrights
find . -iname origin.src | \
awk '{ \
split($0,b,"/"); \
system("xargs < " $0 " curl --create-dirs -Lo ./sources/" b[2] ".zip " $2)}' && \
find -regex './sources$' | awk '{system("zip -jr ./3rd-party-sources.zip " $0)}'
mkdir -p ../license-obligations && mv `find . -regex "^./3rd-party-.*.zip$"` ../license-obligations/
- name: Update Release with license obligations resources
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: ${{ env.WORKING_DIRECTORY }}/license-obligations/*
artifactErrorsFailBuild: true
makeLatest: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
- name: Log in to container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=match,pattern=service-v(\d+.\d+.\d+),group=1
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version-file: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}/go.mod
cache-dependency-path: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}/go.sum
- name: Setup Ko
uses: imjasonh/[email protected]
- name: Publish Docker Images
run: |
# Generate tags flag (Metadata action output is newline delimited entries like
# 'ghcr.io/carbynestack/ephemeral:0.1.10' and we only need the part after the colon)
readarray -t tags < <( echo "${{ steps.meta.outputs.tags }}" )
for i in "${!tags[@]}"; do
readarray -d ":" -t parts < <( echo "${tags[i]}" )
tags[i]=$(echo "${parts[1]}" | tr -d '\n')
done
printf -v joined_tags "%s," "${tags[@]}"
# Generate label flags
readarray -t labels < <( echo "${{ steps.meta.outputs.labels }}" )
printf -v label_flags -- "--image-label=%s " "${labels[@]}"
# Publish using ko
ko publish -B \
--tags="${joined_tags%,}" \
"${label_flags}" \
github.com/carbynestack/ephemeral/cmd/discovery \
github.com/carbynestack/ephemeral/cmd/ephemeral \
github.com/carbynestack/ephemeral/cmd/network-controller