-
-
Notifications
You must be signed in to change notification settings - Fork 8
151 lines (128 loc) · 3.87 KB
/
ci.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
139
140
141
142
143
144
145
146
147
148
149
150
151
name: CI
on:
- push
- pull_request
jobs:
build-ubuntu:
name: Build on Ubuntu x86_64 with ${{ matrix.CC }}
runs-on: ubuntu-latest
strategy:
matrix:
CC:
- gcc
- clang
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install build dependencies
run: sudo apt-get install asciidoctor
- run: make build CC=${{ matrix.CC }}
- run: ./build/tty-copy -V
- run: make install DESTDIR=dest
build-alpine:
name: Build on Alpine ${{ matrix.ARCH }} with ${{ matrix.CC }} ${{ matrix.LDFLAGS }}
runs-on: ubuntu-latest
strategy:
matrix:
ARCH:
- x86_64
- aarch64
- armv7
- ppc64le
- riscv64
CC:
- gcc
LDFLAGS:
- ''
- -static -s
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all history
- name: Install latest Alpine Linux for ${{ matrix.ARCH }}
uses: jirutka/setup-alpine@v1
with:
arch: ${{ matrix.ARCH }}
branch: ${{ matrix.ARCH == 'riscv64' && 'edge' || 'latest-stable' }}
packages: asciidoctor build-base
- name: Get version
run: |
GIT_TAG=$(git describe --tags --match 'v*' 2>/dev/null || echo ${GITHUB_REF##*/})
echo "VERSION=${GIT_TAG#v}" >> $GITHUB_ENV
- name: Build tty-copy
run: |
make build CC=${{ matrix.CC }} LDFLAGS="${{ matrix.LDFLAGS }}" VERSION="${{ env.VERSION }}"
ls -lah build/
file build/tty-copy
shell: alpine.sh {0}
- name: tty-copy -V
run: ./build/tty-copy -V
shell: alpine.sh {0}
- name: Rename binary before upload
if: ${{ matrix.LDFLAGS != '' }}
run: |
mkdir dist
cp -a build/tty-copy dist/tty-copy.${{ matrix.ARCH }}-linux
- name: Upload binary to artifacts
if: ${{ matrix.LDFLAGS != '' }}
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.ARCH }}-linux"
path: dist/*
if-no-files-found: error
build-macos:
name: Build on macOS x86_64
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all history
- name: Install dependencies
run: brew install asciidoctor
- name: Get version
run: |
GIT_TAG=$(git describe --tags --match 'v*' 2>/dev/null || echo ${GITHUB_REF##*/})
echo "VERSION=${GIT_TAG#v}" >> $GITHUB_ENV
- name: Build tty-copy
run: |
make build VERSION="${{ env.VERSION }}"
ls -lah build/
file build/tty-copy
- name: tty-copy -V
run: ./build/tty-copy -V
- run: make install DESTDIR=dest
- name: Rename binary before upload
run: |
mkdir dist
cp -a build/tty-copy dist/tty-copy.x86_64-darwin
- name: Upload binary to artifacts
uses: actions/upload-artifact@v4
with:
name: x86_64-darwin
path: dist/*
if-no-files-found: error
publish:
name: Publish binaries to Releases
if: ${{ startsWith(github.ref, 'refs/tags/v') && github.event_name != 'pull_request' }}
needs:
- build-alpine
- build-macos
runs-on: ubuntu-20.04
steps:
- name: Download binaries from artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Generate checksums.txt
run:
shasum -a 256 * > checksums.txt
working-directory: binaries
- name: Upload binaries to Releases
uses: softprops/action-gh-release@v1
with:
files: binaries/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}