-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (116 loc) · 3.7 KB
/
release.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Release
on:
workflow_dispatch:
push:
tags:
- 'v*'
branches:
- master
paths:
- "cmd/run/**"
- ".github/**"
- "pkg/**"
- go.* # go.mod, and go.sum
- flake.*
permissions:
contents: write
packages: write
jobs:
build-binary:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-14, macos-13]
arch: [amd64, arm64]
include:
- os: ubuntu-latest
platform: linux
- os: macos-13
platform: darwin
- os: macos-14
platform: darwin
exclude:
- os: macos-14
arch: amd64
- os: macos-13
arch: arm64
name: Building run-${{ matrix.platform }}-${{ matrix.arch }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: nxtcoder17/actions/setup-cache-go@v1
with:
cache_key: "run-${{ matrix.platform }}-${{ matrix.arch }}"
working_directory: .
- uses: nxtcoder17/actions/generate-image-tag@v1
- uses: nxtcoder17/actions/setup-nix-cachix@v1
with:
flake_lock: "./flake.lock"
nix_develop_arguments: ".#default"
cachix_cache_name: ${{ secrets.CACHIX_CACHE_NAME }}
cachix_auth_token: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Build Binary
shell: bash
env:
CGO_ENABLED: 0
run: |+
binary=bin/run-${{ matrix.platform }}-${{ matrix.arch }}
go build -o $binary -ldflags="-s -w" -tags urfave_cli_no_docs cmd/run/main.go
if [ "${{ matrix.platform }}" = "linux" ]; then
upx $binary
fi
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: run-${{ matrix.platform }}-${{ matrix.arch }}
path: bin/*
release:
needs: build-binary
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/binaries
pattern: "run-*"
- name: flattening all the executable artifacts
shell: bash
run: |+
ls -R ${{ github.workspace }}/binaries
mkdir -p ${{ github.workspace }}/upload/binaries
shopt -s globstar
file ./** | grep 'executable,' | awk -F: '{print $1}' | xargs -I {} cp {} ${{ github.workspace }}/upload/binaries
shopt -u globstar
- uses: nxtcoder17/actions/generate-image-tag@v1
- name: running for master branch
if: startsWith(github.ref, 'refs/heads/master')
run: |+
echo "IMAGE_TAG=nightly" | tee -a $GITHUB_ENV | tee -a $GITHUB_OUTPUT
- name: ensure github release exists
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |+
set +e
gh release list -R ${{ github.repository }} | grep -i $IMAGE_TAG
exit_code=$?
if [ $exit_code -ne 0 ]; then
gh release create $IMAGE_TAG -R ${{ github.repository }} --generate-notes --prerelease --draft=false
fi
- name: upload to github release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |+
extra_args=""
if [ "$IMAGE_TAG" = "nightly" ]; then
extra_args="--clobber"
fi
gh release upload $IMAGE_TAG -R ${{github.repository}} $extra_args ${{github.workspace}}/upload/binaries/*
- name: mark release as latest
if: startsWith(github.ref, 'refs/tags/')
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |+
gh release edit $IMAGE_TAG -R ${{ github.repository }} --latest