-
Notifications
You must be signed in to change notification settings - Fork 15
130 lines (108 loc) · 3.83 KB
/
deploy.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
name: Deploy
on:
push:
tags:
- 'micro-*.*.*'
jobs:
deploy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 11
distribution: adopt
- name: Set up Node 18
uses: actions/setup-node@v3
with:
node-version: 18
- name: Publish collector locally
run: |
git clone --branch 3.2.0 --depth 1 https://github.com/snowplow/stream-collector.git
cd stream-collector
sbt +publishLocal
- name: Run sbt
run: sbt test
- name: Get tag and tracker version information
id: version
run: |
echo ::set-output name=TAG_VERSION::${GITHUB_REF#refs/*/}
echo "##[set-output name=MICRO_VERSION;]$(sbt version -Dsbt.log.noformat=true | perl -ne 'print "$1\n" if /info.*(\d+\.\d+\.\d+[^\r\n]*)/' | tail -n 1 | tr -d '\n')"
- name: Fail if version mismatch
if: ${{ steps.version.outputs.TAG_VERSION != format('micro-{0}', steps.version.outputs.MICRO_VERSION) }}
run: |
echo "Tag version (${{ steps.version.outputs.TAG_VERSION }}) doesn't match version in project (${{ format('micro-{0}', steps.version.outputs.MICRO_VERSION) }})"
exit 1
- name: Build the UI
working-directory: ui
env:
NEXT_PUBLIC_MICRO_HOSTNAME: ''
NEXT_PUBLIC_MUI_LICENSE_KEY: ${{ secrets.MUI_LICENSE }}
run: |
npm install
npm run build
- name: Build artifacts
run: sbt 'project micro' assembly
- name: Create GitHub release and attach artifacts
uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: true
name: Version ${{ steps.version.outputs.MICRO_VERSION }}
tag_name: ${{ steps.version.outputs.TAG_VERSION }}
files: |
target/scala-2.12/assembled_jars/snowplow-micro-${{ steps.version.outputs.MICRO_VERSION }}.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Stage the Docker build
run: sbt "project micro" docker:stage
- name: Stage the Docker distroless build
run: sbt "project microDistroless" docker:stage
- name: Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: snowplow/snowplow-micro
tags: |
type=raw,value=latest,enable=${{ !contains(steps.version.outputs.MICRO_VERSION, 'rc') }}
type=raw,value=${{ steps.version.outputs.MICRO_VERSION }}
flavor: |
latest=false
- name: Docker metadata distroless
id: distroless-meta
uses: docker/metadata-action@v3
with:
images: snowplow/snowplow-micro
tags: |
type=raw,value=latest-distroless,enable=${{ !contains(steps.ver.outputs.MICRO_VERSION, 'rc') }}
type=raw,value=${{ steps.version.outputs.MICRO_VERSION }}-distroless
flavor: |
latest=false
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build image
uses: docker/build-push-action@v2
with:
context: target/docker/stage
file: target/docker/stage/Dockerfile
platforms: linux/amd64,linux/arm64/v8
tags: ${{ steps.meta.outputs.tags }}
push: true
- name: Build distroless image
uses: docker/build-push-action@v2
with:
context: distroless/micro/target/docker/stage
file: distroless/micro/target/docker/stage/Dockerfile
platforms: linux/amd64,linux/arm64/v8
tags: ${{ steps.distroless-meta.outputs.tags }}
push: true