forked from redboxllc/scuttle
-
Notifications
You must be signed in to change notification settings - Fork 4
54 lines (52 loc) · 1.88 KB
/
release.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
name: Main
on: [push, pull_request]
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
# On tag, get tag version without v (e.g. v1.0.0 -> 1.0.0, v1.1.1-beta -> 1.1.1-beta)
- name: Get tag version
id: get_version
run: |
if [[ $GITHUB_REF == "refs/tags/v"* ]]; then
echo "Found release tag"
VERSION=${GITHUB_REF/refs\/tags\/v}
else
echo "No release tag found"
VERSION="local-build-only"
fi
echo "Using version: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
# Build and test binary
- name: Build and Test Binary
env:
CGO_ENABLED: 0
run: |
go mod download
go test -test.timeout 50s
GOOS=linux GOARCH=amd64 go build -o build/linux/amd64/scuttle -ldflags="-X 'main.Version=${{ steps.get_version.outputs.VERSION }}'"
# Build Docker image
# On tag, push Docker image
- name: Build Docker Image
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
repository: kvij/scuttle
tags: latest,${{ steps.get_version.outputs.VERSION }}
push: ${{ startsWith(github.ref, 'refs/tags/') }}
build_args: VERSION=${{ steps.get_version.outputs.VERSION }}
# On tag, Pack zip of scuttle for GitHub Release
- name: Pack
run: |
mkdir build/artifacts
zip -r -j build/artifacts/scuttle-linux-amd64.zip build/linux/amd64/
if: startsWith(github.ref, 'refs/tags/')
# On tag, Create GitHub Release
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: build/artifacts/*.zip