Skip to content

Commit 76cfc90

Browse files
committed
Update docker.yml
Fix out of memory error on GH Actions build and automate GitHub Release with artifacts ( #47). See docker/build-push-action#654 (comment) and docker/build-push-action#621
1 parent 4362d93 commit 76cfc90

File tree

3 files changed

+156
-6
lines changed

3 files changed

+156
-6
lines changed

.github/workflows/docker.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@ name: Docker Image
22

33
on:
44
push:
5-
branches:
6-
- "master"
75
tags:
8-
- "v*"
9-
pull_request:
10-
branches:
11-
- "master"
6+
- v[0-9]+.[0-9]+.[0-9]+*
127

138
jobs:
149
docker_image:

.github/workflows/gh-release.yml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: GitHub Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v[0-9]+.[0-9]+.[0-9]+*
7+
8+
jobs:
9+
release:
10+
name: Publish to Github Releases
11+
outputs:
12+
rc: ${{ steps.check-tag.outputs.rc }}
13+
strategy:
14+
matrix:
15+
include:
16+
- target: aarch64-unknown-linux-musl
17+
os: ubuntu-latest
18+
use-cross: true
19+
cargo-flags: ""
20+
- target: aarch64-apple-darwin
21+
os: macos-latest
22+
use-cross: true
23+
cargo-flags: ""
24+
- target: aarch64-pc-windows-msvc
25+
os: windows-latest
26+
use-cross: true
27+
cargo-flags: "--no-default-features"
28+
- target: x86_64-apple-darwin
29+
os: macos-latest
30+
cargo-flags: ""
31+
- target: x86_64-pc-windows-msvc
32+
os: windows-latest
33+
cargo-flags: ""
34+
- target: x86_64-unknown-linux-musl
35+
os: ubuntu-latest
36+
use-cross: true
37+
cargo-flags: ""
38+
- target: i686-unknown-linux-musl
39+
os: ubuntu-latest
40+
use-cross: true
41+
cargo-flags: ""
42+
- target: i686-pc-windows-msvc
43+
os: windows-latest
44+
use-cross: true
45+
cargo-flags: ""
46+
- target: armv7-unknown-linux-musleabihf
47+
os: ubuntu-latest
48+
use-cross: true
49+
cargo-flags: ""
50+
- target: arm-unknown-linux-musleabihf
51+
os: ubuntu-latest
52+
use-cross: true
53+
cargo-flags: ""
54+
- target: mips-unknown-linux-musl
55+
os: ubuntu-latest
56+
use-cross: true
57+
cargo-flags: "--no-default-features"
58+
- target: mipsel-unknown-linux-musl
59+
os: ubuntu-latest
60+
use-cross: true
61+
cargo-flags: "--no-default-features"
62+
- target: mips64-unknown-linux-gnuabi64
63+
os: ubuntu-latest
64+
use-cross: true
65+
cargo-flags: "--no-default-features"
66+
- target: mips64el-unknown-linux-gnuabi64
67+
os: ubuntu-latest
68+
use-cross: true
69+
cargo-flags: "--no-default-features"
70+
runs-on: ${{matrix.os}}
71+
72+
steps:
73+
- uses: actions/checkout@v2
74+
75+
- name: Check Tag
76+
id: check-tag
77+
shell: bash
78+
run: |
79+
tag=${GITHUB_REF##*/}
80+
echo "::set-output name=version::$tag"
81+
if [[ "$tag" =~ [0-9]+.[0-9]+.[0-9]+$ ]]; then
82+
echo "::set-output name=rc::false"
83+
else
84+
echo "::set-output name=rc::true"
85+
fi
86+
87+
88+
- name: Install Rust Toolchain Components
89+
uses: actions-rs/toolchain@v1
90+
with:
91+
override: true
92+
target: ${{ matrix.target }}
93+
toolchain: stable
94+
profile: minimal # minimal component installation (ie, no documentation)
95+
96+
- name: Show Version Information (Rust, cargo, GCC)
97+
shell: bash
98+
run: |
99+
gcc --version || true
100+
rustup -V
101+
rustup toolchain list
102+
rustup default
103+
cargo -V
104+
rustc -V
105+
106+
- name: Build
107+
uses: actions-rs/cargo@v1
108+
with:
109+
use-cross: ${{ matrix.use-cross }}
110+
command: build
111+
args: --locked --release --target=${{ matrix.target }} ${{ matrix.cargo-flags }}
112+
113+
- name: Build Archive
114+
shell: bash
115+
id: package
116+
env:
117+
target: ${{ matrix.target }}
118+
version: ${{ steps.check-tag.outputs.version }}
119+
run: |
120+
set -euxo pipefail
121+
122+
bin=${GITHUB_REPOSITORY##*/}
123+
src=`pwd`
124+
dist=$src/dist
125+
name=$bin-$version-$target
126+
executable=target/$target/release/$bin
127+
128+
if [[ "$RUNNER_OS" == "Windows" ]]; then
129+
executable=$executable.exe
130+
fi
131+
132+
mkdir $dist
133+
cp $executable $dist
134+
cd $dist
135+
136+
if [[ "$RUNNER_OS" == "Windows" ]]; then
137+
archive=$dist/$name.zip
138+
7z a $archive *
139+
echo "::set-output name=archive::`pwd -W`/$name.zip"
140+
else
141+
archive=$dist/$name.tar.gz
142+
tar czf $archive *
143+
echo "::set-output name=archive::$archive"
144+
fi
145+
146+
- name: Publish Archive
147+
uses: softprops/action-gh-release@v0.1.5
148+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
149+
with:
150+
draft: false
151+
files: ${{ steps.package.outputs.archive }}
152+
prerelease: ${{ steps.check-tag.outputs.rc == 'true' }}
153+
env:
154+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ RUN \
88
DEBIAN_FRONTEND=noninteractive \
99
apt-get update &&\
1010
apt-get -y install ca-certificates tzdata &&\
11+
CARGO_NET_GIT_FETCH_WITH_CLI=true \
1112
cargo build --release
1213

1314
# https://hub.docker.com/r/bitnami/minideb

0 commit comments

Comments
 (0)