Skip to content

Commit 788dfa2

Browse files
authored
Build more binary releases (#395)
* Build more binary releases
1 parent 440ccf3 commit 788dfa2

File tree

3 files changed

+198
-43
lines changed

3 files changed

+198
-43
lines changed

.github/build/friendly-filenames.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"android-arm64": { "friendlyName": "android-arm64-v8a" },
3+
"darwin-amd64": { "friendlyName": "darwin-amd64" },
4+
"darwin-arm64": { "friendlyName": "darwin-arm64" },
5+
"dragonfly-amd64": { "friendlyName": "dragonfly-amd64" },
6+
"freebsd-386": { "friendlyName": "freebsd-386" },
7+
"freebsd-amd64": { "friendlyName": "freebsd-amd64" },
8+
"freebsd-arm64": { "friendlyName": "freebsd-arm64-v8a" },
9+
"freebsd-arm7": { "friendlyName": "freebsd-arm32-v7a" },
10+
"linux-386": { "friendlyName": "linux-386" },
11+
"linux-amd64": { "friendlyName": "linux-amd64" },
12+
"linux-arm5": { "friendlyName": "linux-arm32-v5" },
13+
"linux-arm64": { "friendlyName": "linux-arm64-v8a" },
14+
"linux-arm6": { "friendlyName": "linux-arm32-v6" },
15+
"linux-arm7": { "friendlyName": "linux-armv7" },
16+
"linux-mips64le": { "friendlyName": "linux-mips64le" },
17+
"linux-mips64": { "friendlyName": "linux-mips64" },
18+
"linux-mipslesoftfloat": { "friendlyName": "linux-mips32le-softfloat" },
19+
"linux-mipsle": { "friendlyName": "linux-mips32le" },
20+
"linux-mipssoftfloat": { "friendlyName": "linux-mips32-softfloat" },
21+
"linux-mips": { "friendlyName": "linux-mips32" },
22+
"linux-ppc64le": { "friendlyName": "linux-ppc64le" },
23+
"linux-ppc64": { "friendlyName": "linux-ppc64" },
24+
"linux-riscv64": { "friendlyName": "linux-riscv64" },
25+
"linux-s390x": { "friendlyName": "linux-s390x" },
26+
"openbsd-386": { "friendlyName": "openbsd-386" },
27+
"openbsd-amd64": { "friendlyName": "openbsd-amd64" },
28+
"openbsd-arm64": { "friendlyName": "openbsd-arm64-v8a" },
29+
"openbsd-arm7": { "friendlyName": "openbsd-arm32-v7a" },
30+
"windows-386": { "friendlyName": "windows-386" },
31+
"windows-amd64": { "friendlyName": "windows-amd64" },
32+
"windows-arm7": { "friendlyName": "windows-arm32-v7a" }
33+
}

.github/workflows/release.yml

Lines changed: 163 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,179 @@
1-
name: release
1+
name: Build and Release
2+
23
on:
4+
workflow_dispatch:
5+
release:
6+
types: [published]
37
push:
4-
tags:
5-
- v*
8+
branches:
9+
- master
10+
paths:
11+
- "**/*.go"
12+
- "go.mod"
13+
- "go.sum"
14+
- ".github/workflows/*.yml"
615
jobs:
716
build:
8-
runs-on: ubuntu-latest
917
strategy:
1018
matrix:
11-
GOOS: [ darwin, linux, windows ]
12-
GOARCH: [ amd64 ]
19+
# Include amd64 on all platforms.
20+
goos: [windows, freebsd, openbsd, linux, dragonfly, darwin]
21+
goarch: [amd64, 386]
22+
exclude:
23+
# Exclude i386 on darwin and dragonfly.
24+
- goarch: 386
25+
goos: dragonfly
26+
- goarch: 386
27+
goos: darwin
1328
include:
14-
- GOOS: darwin
15-
GOARCH: amd64
16-
suffix: darwin-amd64
17-
- GOOS: windows
18-
GOARCH: amd64
19-
suffix: windows-amd64.exe
20-
- GOOS: linux
21-
GOARCH: amd64
22-
suffix: linux-amd64
23-
- GOOS: linux
24-
GOARCH: arm
25-
suffix: linux-armv7
29+
# BEIGIN MacOS ARM64
30+
- goos: darwin
31+
goarch: arm64
32+
# END MacOS ARM64
33+
# BEGIN Linux ARM 5 6 7
34+
- goos: linux
35+
goarch: arm
36+
goarm: 7
37+
- goos: linux
38+
goarch: arm
39+
goarm: 6
40+
- goos: linux
41+
goarch: arm
42+
goarm: 5
43+
# END Linux ARM 5 6 7
44+
# BEGIN Android ARM 8
45+
- goos: android
46+
goarch: arm64
47+
# END Android ARM 8
48+
# Windows ARM 7
49+
- goos: windows
50+
goarch: arm
51+
goarm: 7
52+
# BEGIN Other architectures
53+
# BEGIN riscv64 & ARM64
54+
- goos: linux
55+
goarch: arm64
56+
- goos: linux
57+
goarch: riscv64
58+
# END riscv64 & ARM64
59+
# BEGIN MIPS
60+
- goos: linux
61+
goarch: mips64
62+
- goos: linux
63+
goarch: mips64le
64+
- goos: linux
65+
goarch: mipsle
66+
- goos: linux
67+
goarch: mips
68+
# END MIPS
69+
# BEGIN PPC
70+
- goos: linux
71+
goarch: ppc64
72+
- goos: linux
73+
goarch: ppc64le
74+
# END PPC
75+
# BEGIN FreeBSD ARM
76+
- goos: freebsd
77+
goarch: arm64
78+
- goos: freebsd
79+
goarch: arm
80+
goarm: 7
81+
# END FreeBSD ARM
82+
# BEGIN S390X
83+
- goos: linux
84+
goarch: s390x
85+
# END S390X
86+
# END Other architectures
87+
# BEGIN OPENBSD ARM
88+
- goos: openbsd
89+
goarch: arm64
90+
- goos: openbsd
91+
goarch: arm
92+
goarm: 7
93+
# END OPENBSD ARM
94+
fail-fast: false
95+
96+
runs-on: ubuntu-latest
97+
env:
98+
GOOS: ${{ matrix.goos }}
99+
GOARCH: ${{ matrix.goarch }}
100+
GOARM: ${{ matrix.goarm }}
101+
CGO_ENABLED: 0
26102
steps:
27-
- uses: actions/checkout@v2
28-
- uses: actions/setup-go@v2
29-
with:
30-
go-version: 1.16.x
31-
- name: Build ${{ matrix.suffix }} (GOOS=${{ matrix.GOOS }}, GOARCH=${{ matrix.GOARCH }})
32-
env:
33-
GOOS: ${{ matrix.GOOS }}
34-
GOARCH: ${{ matrix.GOARCH }}
35-
CGO_ENABLED: 0
103+
- name: Checkout codebase
104+
uses: actions/checkout@v2
105+
106+
- name: Show workflow information
107+
id: get_filename
36108
run: |
37-
go version
38-
go build -tags netgo -ldflags "-X github.com/dutchcoders/transfer.sh/cmd.Version=${GITHUB_REF##*/} -a -s -w -extldflags '-static'" -o ./artifacts/transfersh-${GITHUB_REF##*/}-${{ matrix.suffix }}
39-
- uses: actions/upload-artifact@v2
40-
name: Upload artifacts
109+
export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOMIPS\"].friendlyName" -r < .github/build/friendly-filenames.json)
110+
echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, GOMIPS: $GOMIPS, RELEASE_NAME: $_NAME"
111+
echo "::set-output name=ASSET_NAME::$_NAME"
112+
echo "::set-output name=GIT_TAG::${GITHUB_REF##*/}"
113+
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
114+
115+
- name: Set up Go
116+
uses: actions/setup-go@v2
41117
with:
42-
name: artifacts
43-
path: ./artifacts
118+
go-version: ^1.16
44119

45-
release:
46-
runs-on: ubuntu-latest
47-
needs: [ build ]
48-
steps:
49-
- uses: actions/download-artifact@v2
50-
name: Download artifacts
120+
- name: Get project dependencies
121+
run: go mod download
122+
123+
- name: Build Transfersh
124+
run: |
125+
mkdir -p build_assets
126+
go build -tags netgo -ldflags "-X github.com/dutchcoders/transfer.sh/cmd.Version=${GITHUB_REF##*/} -a -s -w -extldflags '-static'" -o build_assets/transfersh-${GITHUB_REF##*/}-${ASSET_NAME}
127+
128+
- name: Build Mips softfloat Transfersh
129+
if: matrix.goarch == 'mips' || matrix.goarch == 'mipsle'
130+
run: |
131+
GOMIPS=softfloat go build -tags netgo -ldflags "-X github.com/dutchcoders/transfer.sh/cmd.Version=${GITHUB_REF##*/} -a -s -w -extldflags '-static'" -o build_assets/transfersh-softfloat-${GITHUB_REF##*/}-${ASSET_NAME}
132+
133+
- name: Rename Windows Transfersh
134+
if: matrix.goos == 'windows'
135+
run: |
136+
cd ./build_assets || exit 1
137+
mv transfersh-${GITHUB_REF##*/}-${ASSET_NAME} transfersh-${GITHUB_REF##*/}-${ASSET_NAME}.exe
138+
139+
- name: Prepare to release
140+
run: |
141+
cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md
142+
cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE
143+
144+
- name: Create Gzip archive
145+
shell: bash
146+
run: |
147+
pushd build_assets || exit 1
148+
touch -mt $(date +%Y01010000) *
149+
tar zcvf transfersh-${GITHUB_REF##*/}-${ASSET_NAME}.tar.gz *
150+
mv transfersh-${GITHUB_REF##*/}-${ASSET_NAME}.tar.gz ../
151+
FILE=`find . -name "transfersh-${GITHUB_REF##*/}-${ASSET_NAME}*"`
152+
DGST=$FILE.sha256sum
153+
echo `sha256sum $FILE` > $DGST
154+
popd || exit 1
155+
FILE=./transfersh-${GITHUB_REF##*/}-${ASSET_NAME}.tar.gz
156+
DGST=$FILE.sha256sum
157+
echo `sha256sum $FILE` > $DGST
158+
159+
- name: Change the name
160+
run: |
161+
mv build_assets transfersh-${GITHUB_REF##*/}-${ASSET_NAME}
162+
163+
- name: Upload files to Artifacts
164+
uses: actions/upload-artifact@v2
51165
with:
52-
name: artifacts
53-
path: ./artifacts
54-
- name: Publish artifacts
166+
name: transfersh-${{ steps.get_filename.outputs.GIT_TAG }}-${{ steps.get_filename.outputs.ASSET_NAME }}
167+
path: |
168+
./transfersh-${{ steps.get_filename.outputs.GIT_TAG }}-${{ steps.get_filename.outputs.ASSET_NAME }}/*
169+
170+
- name: Upload binaries to release
55171
uses: softprops/action-gh-release@v1
172+
if: github.event_name == 'release'
56173
with:
57-
files: './artifacts/*'
174+
files: |
175+
./transfersh-${{ steps.get_filename.outputs.GIT_TAG }}-${{ steps.get_filename.outputs.ASSET_NAME }}.tar.gz*
176+
./transfersh-${{ steps.get_filename.outputs.GIT_TAG }}-${{ steps.get_filename.outputs.ASSET_NAME }}/transfersh-${{ steps.get_filename.outputs.GIT_TAG }}-${{ steps.get_filename.outputs.ASSET_NAME }}*
58177
env:
59178
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
179+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ transfersh-server/run.sh
2020
.elasticbeanstalk/*
2121
!.elasticbeanstalk/*.cfg.yml
2222
!.elasticbeanstalk/*.global.yml
23+
24+
!.github/build/

0 commit comments

Comments
 (0)