-
Notifications
You must be signed in to change notification settings - Fork 2
96 lines (86 loc) · 2.56 KB
/
Copy pathrelease.yml
File metadata and controls
96 lines (86 loc) · 2.56 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
88
89
90
91
92
93
94
95
96
name: Release
on:
release:
types: [created]
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: darwin
goarch: amd64
ext: tar.gz
- goos: darwin
goarch: arm64
ext: tar.gz
- goos: linux
goarch: amd64
ext: tar.gz
- goos: linux
goarch: arm64
ext: tar.gz
- goos: windows
goarch: amd64
ext: zip
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: |
TAG="${GITHUB_REF_NAME}"
BINARY="odoo-work-cli"
if [ "${{ matrix.goos }}" = "windows" ]; then
BINARY="odoo-work-cli.exe"
fi
go build -ldflags "-X github.com/seletz/odoo-work-cli/internal/version.Version=${TAG}" \
-o "${BINARY}" ./cmd/odoo-work-cli
- name: Package
run: |
TAG="${GITHUB_REF_NAME}"
BINARY="odoo-work-cli"
if [ "${{ matrix.goos }}" = "windows" ]; then
BINARY="odoo-work-cli.exe"
fi
ARCHIVE="odoo-work-cli-${TAG}-${{ matrix.goos }}-${{ matrix.goarch }}"
if [ "${{ matrix.ext }}" = "tar.gz" ]; then
tar czf "${ARCHIVE}.tar.gz" "${BINARY}"
else
zip "${ARCHIVE}.zip" "${BINARY}"
fi
- name: Upload artifact
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${GITHUB_REF_NAME}"
ARCHIVE="odoo-work-cli-${TAG}-${{ matrix.goos }}-${{ matrix.goarch }}.${{ matrix.ext }}"
gh release upload "$TAG" "$ARCHIVE" --repo "${{ github.repository }}"
checksums:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download assets
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${GITHUB_REF_NAME}"
gh release download "$TAG" --dir assets --repo "${{ github.repository }}"
- name: Generate checksums
run: |
TAG="${GITHUB_REF_NAME}"
cd assets
sha256sum * > "checksums-${TAG}.txt"
- name: Upload checksums
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${GITHUB_REF_NAME}"
gh release upload "$TAG" "assets/checksums-${TAG}.txt" --repo "${{ github.repository }}"