Skip to content

Commit e0907b8

Browse files
author
Marek Dalewski
committed
Initial commit
0 parents  commit e0907b8

File tree

27 files changed

+1530
-0
lines changed

27 files changed

+1530
-0
lines changed

.github/workflows/build-test.yaml

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: "Build & test"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request:
9+
workflow_call:
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
15+
env:
16+
go_version: "^1.19"
17+
18+
jobs:
19+
test:
20+
name: "Test [${{ matrix.os }}]"
21+
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
os:
26+
- ubuntu-latest
27+
- windows-latest
28+
- macOS-latest
29+
30+
runs-on: ${{ matrix.os }}
31+
32+
steps:
33+
34+
- name: "Checkout"
35+
uses: actions/checkout@v3
36+
37+
- name: "Setup Go"
38+
uses: actions/setup-go@v3
39+
with:
40+
go-version: ${{ env.go_version }}
41+
cache: true
42+
43+
- name: "Lint Go code"
44+
uses: golangci/golangci-lint-action@v3
45+
with:
46+
version: latest
47+
48+
- name: "Test project"
49+
run: go test -timeout 5m ./...
50+
51+
build:
52+
name: "Build [${{ matrix.GOOS }}/${{ matrix.GOARCH }}]"
53+
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
GOOS:
58+
- linux
59+
- windows
60+
- darwin
61+
GOARCH:
62+
- amd64
63+
- arm64
64+
APP:
65+
- change-repo
66+
67+
runs-on: ubuntu-latest
68+
69+
steps:
70+
71+
- name: "Checkout"
72+
uses: actions/checkout@v3
73+
74+
- name: "Setup Go"
75+
uses: actions/setup-go@v3
76+
with:
77+
go-version: ${{ env.go_version }}
78+
cache: true
79+
80+
- name: "Extract version"
81+
id: get_version
82+
uses: battila7/get-version-action@v2
83+
84+
- name: "Generate version information"
85+
run: |
86+
GIT_TAG="0.0.0-dev+$(date '+%Y%m%d%H%M%S')"
87+
if [[ "${{ steps.get_version.outputs.is-semver }}" == "true" ]]; then
88+
GIT_TAG="${{ steps.get_version.outputs.version-without-v }}"
89+
fi
90+
GIT_COMMIT=$(git rev-parse HEAD)
91+
92+
echo "GIT_TAG=$GIT_TAG"
93+
echo "GIT_TAG=$GIT_TAG" >> $GITHUB_ENV
94+
echo "GIT_COMMIT=$GIT_COMMIT"
95+
echo "GIT_COMMIT=$GIT_COMMIT" >> $GITHUB_ENV
96+
97+
- name: "Build project [${{ matrix.GOOS }}/${{ matrix.GOARCH }}]"
98+
run: |
99+
mkdir -p dist
100+
GOOS=${{ matrix.GOOS }} GOARCH=${{ matrix.GOARCH }} go build \
101+
-ldflags="-X 'main.Version=$GIT_TAG' -X 'main.Commit=$GIT_COMMIT'" \
102+
-o dist/${{ matrix.APP }}-${{ matrix.GOOS }}-${{ matrix.GOARCH }} \
103+
-v \
104+
.
105+
106+
- name: Archive binaries
107+
uses: actions/upload-artifact@v3
108+
with:
109+
name: ${{ matrix.APP }}-${{ matrix.GOOS }}-${{ matrix.GOARCH }}
110+
path: dist
111+
retention-days: 5

.github/workflows/release.yaml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: "Release"
2+
3+
on:
4+
push:
5+
tags: # run when release has been tagged, however ignore non-official semver tags (release candidates, etc)
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
- "!v[0-9]+.[0-9]+.[0-9]+-*"
8+
9+
env:
10+
go_version: "^1.19"
11+
12+
jobs:
13+
build-test:
14+
name: "Build & test"
15+
16+
uses: ./.github/workflows/build-test.yaml
17+
18+
release:
19+
name: "Release"
20+
21+
needs: build-test
22+
23+
runs-on: "ubuntu-latest"
24+
25+
steps:
26+
27+
- name: "Checkout"
28+
uses: actions/checkout@v3
29+
30+
- name: Download binaries
31+
uses: actions/download-artifact@v3
32+
with:
33+
path: dist
34+
35+
- name: "Release"
36+
uses: "marvinpinto/action-automatic-releases@latest"
37+
with:
38+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
39+
prerelease: false
40+
files: |
41+
LICENSE
42+
dist/*/*

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
.vscode
3+
.tmp

0 commit comments

Comments
 (0)