Skip to content

Commit 5626f8b

Browse files
authored
Merge pull request #1 from jvzantvoort/feat/update-build
new: update build
2 parents 673a6df + 5b5332c commit 5626f8b

11 files changed

Lines changed: 606 additions & 98 deletions

File tree

.github/workflows/audit.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Audit the go source
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
11+
audit:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out code into the Go module directory
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@v4
19+
with:
20+
go-version: ^1.20
21+
id: go
22+
- name: Verify dependencies
23+
run: go mod verify
24+
25+
- name: Build
26+
run: |
27+
CGO_ENABLED=0 GOOS="linux" GOARCH="amd64" go build -v -o build/git-ci ./cmd/git-ci
28+
29+
- name: Run go vet
30+
run: go vet ./...
31+
32+
- name: Install staticcheck
33+
run: go install honnef.co/go/tools/cmd/staticcheck@latest
34+
35+
- name: Run staticcheck
36+
run: staticcheck ./...
37+
38+
- name: Install golint
39+
run: go install golang.org/x/lint/golint@latest
40+
41+
- name: Run golint
42+
run: golint ./...
43+
44+
- name: Run tests
45+
run: go test -race -vet=off ./...

.github/workflows/build.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This workflow will build a golang project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
3+
4+
name: Build the go sources
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
branches: [ main ]
11+
12+
jobs:
13+
14+
build:
15+
name: Build
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Check out code into the Go module directory
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v4
23+
with:
24+
go-version: ^1.20
25+
id: go
26+
27+
- name: Build
28+
run: |
29+
./build.sh package
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
schedule:
7+
- cron: '24 20 * * 3'
8+
9+
permissions:
10+
contents: read
11+
security-events: write
12+
pull-requests: read
13+
actions: read
14+
15+
jobs:
16+
analyze:
17+
name: Analyze
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 30
20+
21+
strategy:
22+
fail-fast: false
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v2
27+
28+
# Initializes the CodeQL tools for scanning.
29+
- name: Initialize CodeQL
30+
uses: github/codeql-action/init@v2
31+
with:
32+
languages: go
33+
34+
- name: Perform CodeQL Analysis
35+
uses: github/codeql-action/analyze@v2

.github/workflows/go.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

.github/workflows/release-go.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
release:
9+
permissions:
10+
contents: write # to upload release asset (actions/upload-release-asset)
11+
12+
name: Release git-ci
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
goos: [linux, darwin]
17+
goarch: [386, amd64, arm64]
18+
exclude:
19+
- goos: darwin
20+
goarch: 386
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v2
25+
26+
- name: Set up Go
27+
uses: actions/setup-go@v2
28+
29+
- name: Download dependencies
30+
run: |
31+
go mod download
32+
33+
- name: Prepare build directory
34+
run: |
35+
mkdir -p build/${{ matrix.goos }}.${{ matrix.goarch }}
36+
37+
- name: Build
38+
env:
39+
GOOS: ${{ matrix.goos }}
40+
GOARCH: ${{ matrix.goarch }}
41+
run: |
42+
find cmd -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | \
43+
while read -r target; do \
44+
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -trimpath -o $GITHUB_WORKSPACE/build/${{ matrix.goos }}.${{ matrix.goarch }} ./cmd/${target}; \
45+
done
46+
47+
- name: Create package
48+
id: package
49+
run: |
50+
PACKAGE_NAME=git-ci.${GITHUB_REF#refs/tags/git-ci-}.${{ matrix.goos }}.${{ matrix.goarch }}.tar.gz
51+
tar -czvf $PACKAGE_NAME -C build/${{ matrix.goos }}.${{ matrix.goarch }} .
52+
echo ::set-output name=name::${PACKAGE_NAME}
53+
54+
- name: Upload asset
55+
uses: actions/upload-release-asset@v1
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
with:
59+
upload_url: ${{ github.event.release.upload_url }}
60+
asset_path: ./${{ steps.package.outputs.name }}
61+
asset_name: ${{ steps.package.outputs.name }}
62+
asset_content_type: application/gzip

0 commit comments

Comments
 (0)