forked from UKCloud/adcs-issuer
-
Notifications
You must be signed in to change notification settings - Fork 1
74 lines (65 loc) · 2.45 KB
/
ci.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
# This is a basic workflow to help you get started with Actions
name: CI - ADCS-Issuer
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
tags:
- "v*"
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
name: Build, release and upload assets
runs-on: ubuntu-latest
steps:
- name: Set up GO
uses: actions/setup-go@v1
with:
go-version: 1.16
- name: Checkout code
uses: actions/checkout@master
- name: Get the version from tag
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
- name: Build
run: |
export GOBIN=$(pwd)/bin
export PATH=$PATH:$GOBIN
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -ldflags="-X 'main.version=$(git describe --tags)' -X 'main.buildTime=$(date)'" -a -o manager-$VERSION-linux-amd64 main.go
echo manager-$VERSION
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
- name: Create release
id: create_release
uses: actions/create-release@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload linux-amd64
id: upload_release_asset_linux
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./manager-${{ steps.get_version.outputs.VERSION }}-linux-amd64
asset_name: manager-${{ steps.get_version.outputs.VERSION }}-linux-amd64
asset_content_type: application/octet-stream
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@master
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
BUILT_BINARY: manager-${{ steps.get_version.outputs.VERSION }}-linux-amd64
DOCKER_BUILDKIT: 1
with:
name: pearj/adcs-issuer
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
buildargs: BUILT_BINARY
dockerfile: ci.Dockerfile
tags: "latest,${{ env.VERSION }}"