-
Notifications
You must be signed in to change notification settings - Fork 7
88 lines (84 loc) · 3.62 KB
/
main.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
name: Go
on:
pull_request:
push:
branches:
- master
jobs:
build:
strategy:
matrix:
go: ["1.18", "1.19"]
env:
DEFAULT_GO: "1.19"
name: Build with go version ${{ matrix.go }}
runs-on: ubuntu-latest
steps:
- name: Set up GoLang ${{ matrix.go }}
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
- name: Run tests
run: go test ./...
- name: Build binary
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
go build -o build/go-semantic-release-temp ./cmd/go-semantic-release/
./build/go-semantic-release-temp next --no-cache --loglevel trace
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o build/go-semantic-release.linux_x86_64 -ldflags "-w -s --X main.version=`./build/go-semantic-release-temp next`" ./cmd/go-semantic-release/
GOOS=windows GOARCH=386 CGO_ENABLED=0 go build -o build/go-semantic-release.windows_i386.exe -ldflags "-w -s -X main.version=`./build/go-semantic-release-temp next`" ./cmd/go-semantic-release/
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o build/go-semantic-release.windows_x86_64.exe -ldflags "-w -s -X main.version=`./build/go-semantic-release-temp next`" ./cmd/go-semantic-release/
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -o build/go-semantic-release.darwin_x86_64 -ldflags "-w -s -X main.version=`./build/go-semantic-release-temp next`" ./cmd/go-semantic-release/
- name: Build Docker image PR
if: github.ref != 'refs/heads/master'
run: |
docker build -t nightapes/go-semantic-release:development-${{matrix.go}} .
- name: Build Docker image master
if: github.ref == 'refs/heads/master'
run: |
docker login -u nightapes -p ${{ secrets.DOCKER_PASSWORD }}
docker login -u nightapes -p ${{ secrets.GITHUB_TOKEN }} docker.pkg.github.com
docker build -t nightapes/go-semantic-release:development-${{matrix.go}} .
docker push nightapes/go-semantic-release:development-${{matrix.go}}
docker tag nightapes/go-semantic-release:development-${{matrix.go}} docker.pkg.github.com/nightapes/go-semantic-release/go-semantic-release:development-${{matrix.go}}
docker push docker.pkg.github.com/nightapes/go-semantic-release/go-semantic-release:development-${{matrix.go}}
- uses: actions/upload-artifact@v1
if: matrix.go == env.DEFAULT_GO
with:
name: build
path: build
release:
name: Release
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- uses: actions/download-artifact@v1
with:
name: build
path: build
- name: Release
if: github.ref == 'refs/heads/master'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
chmod -R +x build
docker login -u nightapes -p ${{ secrets.DOCKER_PASSWORD }}
docker login -u nightapes -p $GITHUB_TOKEN docker.pkg.github.com
./build/go-semantic-release-temp release --loglevel trace
- name: Release PR
if: github.ref != 'refs/heads/master'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
chmod -R +x build
./build/go-semantic-release-temp release --loglevel trace