-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (57 loc) · 1.99 KB
/
main.yml
File metadata and controls
69 lines (57 loc) · 1.99 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
name: build
env:
REGISTRY: ghcr.io
on:
push:
tags:
- '**[0-9]+.[0-9]+.[0-9]+'
jobs:
build-release:
runs-on: ubuntu-20.04
container: maxbytes1/go-build:0.1.1
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set version
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Build RPM
run: |
echo "Building version ${{ env.VERSION }}"
GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=$VERSION" -o bin/okql cmd/main.go
sed -i "s/\!release\!/${{ github.run_id }}/" build/rpm.json
go-bin-rpm generate -o okql.rpm --version ${{ env.VERSION }} --arch amd64 --file build/rpm.json
ls -lah okql.rpm
cp bin/okql . # copy binary to root folder to be able to use it easily in next step
- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: "okql.rpm,okql"
omitBody: true
token: ${{ secrets.GITHUB_TOKEN }}
build-docker-image:
runs-on: ubuntu-20.04
needs: [build-release]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set version
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
- name: Build and push Docker images
uses: docker/build-push-action@v2
with:
context: "./build"
file: "./build/Dockerfile"
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}