Skip to content

Commit 14ab2ec

Browse files
committed
Add release workflow
1 parent c47c302 commit 14ab2ec

File tree

5 files changed

+346
-0
lines changed

5 files changed

+346
-0
lines changed

.github/workflows/release.yml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
7+
8+
jobs:
9+
build:
10+
name: Build
11+
strategy:
12+
matrix:
13+
os: [ linux, freebsd, openbsd, dragonfly, windows, darwin ]
14+
arch: [ amd64, 386 ]
15+
include:
16+
- os: linux
17+
arch: arm
18+
arm: 5
19+
- os: linux
20+
arch: arm
21+
arm: 6
22+
- os: linux
23+
arch: arm
24+
arm: 7
25+
- os: linux
26+
arch: arm64
27+
- os: linux
28+
arch: mips
29+
mips: softfloat
30+
- os: linux
31+
arch: mips
32+
mips: hardfloat
33+
- os: linux
34+
arch: mipsle
35+
mipsle: softfloat
36+
- os: linux
37+
arch: mipsle
38+
mipsle: hardfloat
39+
- os: linux
40+
arch: mips64
41+
- os: linux
42+
arch: mips64le
43+
- os: linux
44+
arch: ppc64
45+
- os: linux
46+
arch: ppc64le
47+
exclude:
48+
- os: darwin
49+
arch: 386
50+
- os: dragonfly
51+
arch: 386
52+
fail-fast: false
53+
runs-on: ubuntu-latest
54+
env:
55+
GOOS: ${{ matrix.os }}
56+
GOARCH: ${{ matrix.arch }}
57+
GOARM: ${{ matrix.arm }}
58+
GOMIPS: ${{ matrix.mips }}
59+
GOMIPS64: ${{ matrix.mips64 }}
60+
GOMIPSLE: ${{ matrix.mipsle }}
61+
steps:
62+
- name: Check out code into the Go module directory
63+
uses: actions/checkout@v2
64+
65+
- name: List checked-out code
66+
run: ls -al
67+
68+
- name: Set up Go 1.x
69+
uses: actions/setup-go@v2
70+
with:
71+
go-version: ^1.15
72+
73+
- name: Build fat binary
74+
id: builder
75+
run: |
76+
ARGS="${GOOS}-${GOARCH}"
77+
if [[ -n "${GOARM}" ]]; then
78+
ARGS="${ARGS}v${GOARM}"
79+
elif [[ -n "${GOMIPS}" ]]; then
80+
ARGS="${ARGS}-${GOMIPS}"
81+
elif [[ -n "${GOMIPS64}" ]]; then
82+
ARGS="${ARGS}-${GOMIPS64}"
83+
elif [[ -n "${GOMIPSLE}" ]]; then
84+
ARGS="${ARGS}-${GOMIPSLE}"
85+
fi
86+
make ${ARGS}
87+
echo "::set-output name=args::${ARGS}"
88+
89+
- name: Archive binary
90+
run: make TARGET=${{ steps.builder.outputs.args }} releases
91+
92+
- name: Upload archived binary
93+
uses: actions/upload-artifact@v2
94+
with:
95+
name: archive-is
96+
path: build/package/archive.is*
97+
98+
checksum:
99+
name: Get archived packages checksum
100+
runs-on: ubuntu-latest
101+
needs: [ build ]
102+
outputs:
103+
digest: ${{ steps.digest.outputs.result }}
104+
steps:
105+
- name: Download math result from build job
106+
uses: actions/download-artifact@v2
107+
with:
108+
name: archive-is
109+
path: .
110+
111+
- name: Create all binary digest
112+
id: digest
113+
run: |
114+
digest=$(find archive.is* -type f -exec sha256sum {} +)
115+
digest="${digest//$'%'/%25}"
116+
digest="${digest//$'\n'/%0A}"
117+
echo "::set-output name=result::$digest"
118+
119+
release:
120+
name: Create and upload release
121+
runs-on: ubuntu-latest
122+
needs: [build, checksum]
123+
steps:
124+
- name: Download math result from build and checksum jobs
125+
uses: actions/download-artifact@v2
126+
with:
127+
name: archive-is
128+
path: archive-is # Put files to archive.is directory
129+
130+
- name: Create Release
131+
uses: actions/create-release@v1
132+
env:
133+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
134+
with:
135+
tag_name: ${{ github.ref }}
136+
release_name: Release ${{ github.ref }}
137+
body: |
138+
**Digests in this release:**
139+
140+
```
141+
${{ needs.checksum.outputs.digest }}
142+
```
143+
draft: false
144+
prerelease: true
145+
146+
- name: Upload release assets
147+
uses: fnkr/github-action-ghr@v1
148+
if: startsWith(github.ref, 'refs/tags/')
149+
env:
150+
GHR_PATH: archive-is/
151+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Makefile

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
export GO111MODULE = on
2+
export GOPROXY = https://proxy.golang.org
3+
4+
NAME = archive.is
5+
BINDIR ?= ./build/binary
6+
PACKDIR ?= ./build/package
7+
LDFLAGS := $(shell echo "-X 'archive.is/version.Version=`git describe --tags --abbrev=0`'")
8+
LDFLAGS := $(shell echo "${LDFLAGS} -X 'archive.is/version.Commit=`git rev-parse --short HEAD`'")
9+
LDFLAGS := $(shell echo "${LDFLAGS} -X 'archive.is/version.BuildDate=`date +%FT%T%z`'")
10+
GOBUILD ?= CGO_ENABLED=0 go build -trimpath --ldflags "-s -w ${LDFLAGS} -buildid=" -v
11+
VERSION ?= $(shell git describe --tags `git rev-list --tags --max-count=1` | sed -e 's/v//g')
12+
GOFILES ?= $(wildcard ./cmd/archive.is/*.go)
13+
PROJECT := github.com/wabarc/archive.is
14+
PACKAGES ?= $(shell go list ./...)
15+
16+
PLATFORM_LIST = \
17+
darwin-amd64 \
18+
linux-386 \
19+
linux-amd64 \
20+
linux-armv5 \
21+
linux-armv6 \
22+
linux-armv7 \
23+
linux-arm64 \
24+
linux-mips-softfloat \
25+
linux-mips-hardfloat \
26+
linux-mipsle-softfloat \
27+
linux-mipsle-hardfloat \
28+
linux-mips64 \
29+
linux-mips64le \
30+
linux-ppc64 \
31+
linux-ppc64le \
32+
freebsd-386 \
33+
freebsd-amd64 \
34+
openbsd-386 \
35+
openbsd-amd64 \
36+
dragonfly-amd64
37+
38+
WINDOWS_ARCH_LIST = \
39+
windows-386 \
40+
windows-amd64
41+
42+
.PHONY: \
43+
darwin-386 \
44+
darwin-amd64 \
45+
linux-386 \
46+
linux-amd64 \
47+
linux-armv5 \
48+
linux-armv6 \
49+
linux-armv7 \
50+
linux-arm64 \
51+
linux-mips-softfloat \
52+
linux-mips-hardfloat \
53+
linux-mipsle-softfloat \
54+
linux-mipsle-hardfloat \
55+
linux-mips64 \
56+
linux-mips64le \
57+
linux-ppc64 \
58+
linux-ppc64le \
59+
freebsd-386 \
60+
freebsd-amd64 \
61+
openbsd-386 \
62+
openbsd-amd64 \
63+
windows-386 \
64+
windows-amd64 \
65+
all-arch \
66+
tar_releases \
67+
zip_releases \
68+
releases \
69+
clean \
70+
test \
71+
fmt \
72+
rpm \
73+
debian \
74+
debian-packages \
75+
docker-image
76+
77+
darwin-386:
78+
GOARCH=386 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
79+
80+
darwin-amd64:
81+
GOARCH=amd64 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
82+
83+
darwin-arm64:
84+
GOARCH=arm64 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
85+
86+
linux-386:
87+
GOARCH=386 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
88+
89+
linux-amd64:
90+
GOARCH=amd64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
91+
92+
linux-armv5:
93+
GOARCH=arm GOOS=linux GOARM=5 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
94+
95+
linux-armv6:
96+
GOARCH=arm GOOS=linux GOARM=6 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
97+
98+
linux-armv7:
99+
GOARCH=arm GOOS=linux GOARM=7 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
100+
101+
linux-armv8: linux-arm64
102+
linux-arm64:
103+
GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
104+
105+
linux-mips-softfloat:
106+
GOARCH=mips GOMIPS=softfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
107+
108+
linux-mips-hardfloat:
109+
GOARCH=mips GOMIPS=hardfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
110+
111+
linux-mipsle-softfloat:
112+
GOARCH=mipsle GOMIPS=softfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
113+
114+
linux-mipsle-hardfloat:
115+
GOARCH=mipsle GOMIPS=hardfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
116+
117+
linux-mips64:
118+
GOARCH=mips64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
119+
120+
linux-mips64le:
121+
GOARCH=mips64le GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
122+
123+
linux-ppc64:
124+
GOARCH=ppc64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
125+
126+
linux-ppc64le:
127+
GOARCH=ppc64le GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
128+
129+
freebsd-386:
130+
GOARCH=386 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
131+
132+
freebsd-amd64:
133+
GOARCH=amd64 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
134+
135+
openbsd-386:
136+
GOARCH=386 GOOS=openbsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
137+
138+
openbsd-amd64:
139+
GOARCH=amd64 GOOS=openbsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
140+
141+
windows-386:
142+
GOARCH=386 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe $(GOFILES)
143+
144+
windows-amd64:
145+
GOARCH=amd64 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe $(GOFILES)
146+
147+
dragonfly-amd64:
148+
GOARCH=amd64 GOOS=dragonfly $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(GOFILES)
149+
150+
ifeq ($(TARGET),)
151+
tar_releases := $(addsuffix .gz, $(PLATFORM_LIST))
152+
zip_releases := $(addsuffix .zip, $(WINDOWS_ARCH_LIST))
153+
else
154+
ifeq ($(findstring windows,$(TARGET)),windows)
155+
zip_releases := $(addsuffix .zip, $(TARGET))
156+
else
157+
tar_releases := $(addsuffix .gz, $(TARGET))
158+
endif
159+
endif
160+
161+
$(tar_releases): %.gz : %
162+
chmod +x $(BINDIR)/$(NAME)-$(basename $@)
163+
tar -czf $(PACKDIR)/$(NAME)-$(basename $@)-$(VERSION).tar.gz --transform "s/.*\///g" $(BINDIR)/$(NAME)-$(basename $@)
164+
165+
$(zip_releases): %.zip : %
166+
zip -m -j $(PACKDIR)/$(NAME)-$(basename $@)-$(VERSION).zip $(BINDIR)/$(NAME)-$(basename $@).exe
167+
168+
all-arch: $(PLATFORM_LIST) $(WINDOWS_ARCH_LIST)
169+
170+
releases: $(tar_releases) $(zip_releases)
171+
172+
clean:
173+
rm -f $(BINDIR)/*
174+
rm -f $(PACKDIR)/*
175+
rm -rf data-dir*
176+
177+
fmt:
178+
@echo "-> Running go fmt"
179+
@go fmt $(PACKAGES)
180+
181+
test:
182+
@echo "-> Running go test"
183+
go test -v ./...

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,20 @@ This package is a command-line tool named `archive.is` saving webpage to [archiv
44

55
## Installation
66

7+
From source:
8+
79
```sh
810
$ go get github.com/wabarc/archive.is
911
```
1012

13+
From [gobinaries.com](https://gobinaries.com):
14+
15+
```sh
16+
$ curl -sf https://gobinaries.com/wabarc/archive.is | sh
17+
```
18+
19+
From [releases](https://github.com/wabarc/archive.is/releases)
20+
1121
## Usage
1222

1323
#### Command-line

build/binary/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
archive.is*

build/package/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
archive.is*

0 commit comments

Comments
 (0)