Repository navigation
87 lines (82 loc) · 3.03 KB
/
Copy pathrelease.yml
File metadata and controls
87 lines (82 loc) · 3.03 KB
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
name: Release
on:
push:
branches: [main]
tags: ["v*"]
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
strategy:
matrix:
include:
- { goos: darwin, goarch: arm64, asset: Darwin_arm64 }
- { goos: darwin, goarch: amd64, asset: Darwin_x86_64 }
- { goos: linux, goarch: arm64, asset: Linux_arm64 }
- { goos: linux, goarch: amd64, asset: Linux_x86_64 }
- { goos: windows, goarch: arm64, asset: Windows_arm64 }
- { goos: windows, goarch: amd64, asset: Windows_x86_64 }
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "0"
run: |
mkdir -p dist
binary=yolocoder
if [ "$GOOS" = windows ]; then binary=yolocoder.exe; fi
version="${{ github.ref_name }}"
if [ "${{ github.ref_type }}" != tag ]; then version=main; fi
go build -trimpath \
-ldflags "-s -w -X github.com/mindsdb/yolocoder/internal/version.Version=$version -X github.com/mindsdb/yolocoder/internal/version.Commit=${{ github.sha }}" \
-o "dist/$binary" ./cmd/yolocoder
- name: Package
run: |
cd dist
if [ "${{ matrix.goos }}" = windows ]; then
zip "yolocoder_${{ matrix.asset }}.zip" yolocoder.exe
rm yolocoder.exe
else
tar -czf "yolocoder_${{ matrix.asset }}.tar.gz" yolocoder
rm yolocoder
fi
- uses: actions/upload-artifact@v4
with:
name: yolocoder_${{ matrix.asset }}
path: dist/*
retention-days: 1
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Generate metadata
run: |
cd dist
sha256sum * > checksums.txt
echo "${{ github.sha }}" > commit.txt
- uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_type == 'tag' && github.ref_name || 'latest' }}
name: ${{ github.ref_type == 'tag' && github.ref_name || 'Latest (main)' }}
body: ${{ github.ref_type == 'tag' && '' || format('Continuous build from main at {0}.', github.sha) }}
generate_release_notes: ${{ github.ref_type == 'tag' }}
# The install scripts install GitHub's "Latest" release, and the
# continuous build from main is the one they should get. A tag
# (e.g. a pinned v0.0.0-23f5fce, run with yolocoder --release)
# never takes that badge, and one with a "-" is a pre-release.
prerelease: ${{ github.ref_type == 'tag' && contains(github.ref_name, '-') }}
make_latest: ${{ github.ref_type == 'tag' && 'false' || 'true' }}
files: dist/*