-
Notifications
You must be signed in to change notification settings - Fork 74
144 lines (121 loc) · 4.48 KB
/
release.yml
File metadata and controls
144 lines (121 loc) · 4.48 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
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
139
140
141
142
143
144
name: Build and Release
on:
workflow_dispatch:
inputs:
version:
description: "Version to release"
required: true
push:
tags:
- v*
permissions:
contents: write
actions: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
container: debian:10
steps:
- name: Set build version
run: |
set -e
INPUT_VERSION=${{ github.event.inputs.version }}
version=${INPUT_VERSION:-${GITHUB_REF##*/}}
echo "GO_DRIVE_VERSION=${version}" >> $GITHUB_ENV
- name: Install tools
run: |
# debian 10 is end of life, so we need to use archive.debian.org
sed -i 's|deb.debian.org|archive.debian.org|g' /etc/apt/sources.list
sed -i 's|security.debian.org|archive.debian.org|g' /etc/apt/sources.list
sed -i '/buster-updates/d' /etc/apt/sources.list
apt-get update -y && apt-get install -y git curl tar zip build-essential gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf gcc-mingw-w64-x86-64
curl -s -L https://github.com/mislav/hub/releases/download/v2.14.2/hub-linux-amd64-2.14.2.tgz -o /tmp/hub.tgz
mkdir /tmp/hub-installer
tar xf /tmp/hub.tgz --strip-components 1 -C /tmp/hub-installer
/tmp/hub-installer/install
- name: Cache downloaded cross-build environment
id: cache-cross-build-env
uses: actions/cache@v4
with:
path: /tmp/cross-build-env
key: aarch64_arm_amd64
- name: Download cross-build environment
if: steps.cache-cross-build-env.outputs.cache-hit != 'true'
run: |
set -e
mkdir -p /tmp/cross-build-env
pkg_file=/tmp/cross-build-env/packages
echo aarch64-linux-musl-cross >> $pkg_file
echo arm-linux-musleabihf-cross >> $pkg_file
echo x86_64-linux-musl-cross >> $pkg_file
base_url=https://github.com/devld/go-drive/releases/download/musl-building-toolchain/
for i in `cat ${pkg_file}`; do
url="${base_url}${i}.tgz"
echo "downloading ${i} from ${url}"
curl -s -L -o "/tmp/cross-build-env/${i}.tgz" "${url}"
done
- name: Setup cross-build environment
run: |
set -e
pkg_file=/tmp/cross-build-env/packages
for i in `cat ${pkg_file}`; do
tar xf "/tmp/cross-build-env/${i}.tgz" --strip-components 1 -C /usr/local
done
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "^1.25.6"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
- name: Check out code
uses: actions/checkout@v4
- name: Configure git
run: git config --global --add safe.directory $(pwd)
- name: Show building env info
run: |
ldd --version
hub --version
go version
npm --version
node --version
git log -n1
- name: Test
run: go test -v ./...
- name: Build
shell: bash
run: |
set -e
export BUILD_VERSION=${GO_DRIVE_VERSION}
BUILDS=( linux_amd64 windows_amd64 linux_arm64 linux_arm linux_musl_amd64 linux_musl_arm64 linux_musl_arm)
CGO_ARGS=(gcc x86_64-w64-mingw32-gcc aarch64-linux-gnu-gcc arm-linux-gnueabihf-gcc x86_64-linux-musl-gcc aarch64-linux-musl-gcc arm-linux-musleabihf-gcc)
make clean
for i in "${!BUILDS[@]}"; do
os_arch=${BUILDS[$i]}
cgo_cc=${CGO_ARGS[$i]}
export GOOS=${os_arch%%_*}
export GOARCH=${os_arch##*_}
echo building for ${os_arch}
target=all
if [ ${GOOS} == 'windows' ]; then
target=zip
fi
export CC=
export CGO_ENABLED=1
if [ ! -z "$cgo_cc" ]; then
export CC=${cgo_cc}
fi
make ${target} target_name="go-drive_${os_arch}"
done
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
for i in `find build/ -maxdepth 1 -type f -name '*.tar.gz' -or -name '*.zip'`; do
echo "adding artifact: ${i}"
assets="${assets} -a ${i}"
done
hub release create -d -p ${assets} -m "Release ${GO_DRIVE_VERSION}" ${GO_DRIVE_VERSION}