Skip to content

Commit b6e9119

Browse files
committed
Github workflows
1 parent c13d4a8 commit b6e9119

File tree

11 files changed

+337
-94
lines changed

11 files changed

+337
-94
lines changed

.github/workflows/release.yml

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
workflow_call:
8+
secrets:
9+
DOCKER_PASSWORD:
10+
required: true
11+
12+
permissions:
13+
contents: write
14+
15+
env:
16+
PROJECT_NAME: rustyhogs
17+
18+
jobs:
19+
dist-binaries:
20+
name: Dist Binaries
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
fail-fast: true
24+
matrix:
25+
build: [x86_64-linux, x86_64-macos, x86_64-windows]
26+
include:
27+
- build: x86_64-linux
28+
os: ubuntu-latest
29+
rust: stable
30+
target: x86_64-unknown-linux-gnu
31+
cross: false
32+
- build: x86_64-macos
33+
os: macos-latest
34+
rust: stable
35+
target: x86_64-apple-darwin
36+
cross: false
37+
# - build: aarch64-macos
38+
# os: macos-13-xlarge
39+
# rust: stable
40+
# target: aarch64-apple-darwin
41+
# cross: false
42+
- build: x86_64-windows
43+
os: windows-2019
44+
rust: stable
45+
target: x86_64-pc-windows-msvc
46+
cross: false
47+
steps:
48+
- name: Checkout sources
49+
uses: actions/checkout@v3
50+
- name: Install ${{ matrix.rust }}-${{ matrix.target }} toolchain
51+
uses: actions-rs/toolchain@v1
52+
with:
53+
profile: minimal
54+
toolchain: ${{ matrix.rust }}
55+
target: ${{ matrix.target }}
56+
override: true
57+
- name: Build release binaries
58+
uses: actions-rs/cargo@v1
59+
with:
60+
use-cross: ${{ matrix.cross }}
61+
command: build
62+
args: --release --target ${{ matrix.target }}
63+
- name: Build archive
64+
shell: bash
65+
run: |
66+
mkdir dist
67+
ls -lah target/${{ matrix.target }}/release
68+
if [[ ${{ matrix.build }} =~ "windows" ]]; then
69+
echo "${{ matrix.build }}: using .exe extension"
70+
exe=".exe"
71+
fi
72+
cp ./target/${{ matrix.target }}/release/*_hog$exe dist
73+
- uses: actions/upload-artifact@v3
74+
with:
75+
name: bins-${{ matrix.build }}
76+
path: dist
77+
dist-lambda:
78+
name: Dist Lambda
79+
runs-on: ubuntu-latest
80+
steps:
81+
- name: Checkout sources
82+
uses: actions/checkout@v3
83+
- name: Install stable-x86_64-unknown-linux-musl toolchain
84+
uses: actions-rs/toolchain@v1
85+
with:
86+
profile: minimal
87+
toolchain: stable
88+
target: x86_64-unknown-linux-musl
89+
override: true
90+
- name: Build release binaries
91+
uses: actions-rs/cargo@v1
92+
with:
93+
use-cross: true
94+
command: build
95+
args: --release --target x86_64-unknown-linux-musl
96+
- name: Build archive
97+
shell: bash
98+
run: |
99+
mkdir dist
100+
cp ./target/x86_64-unknown-linux-musl/release/*_lambda dist
101+
- uses: actions/upload-artifact@v3
102+
with:
103+
name: bins-lambda
104+
path: dist
105+
dist-docker:
106+
name: Dist Docker
107+
runs-on: ubuntu-latest
108+
steps:
109+
- name: Checkout sources
110+
uses: actions/checkout@v3
111+
- name: Get tag name
112+
id: tagname
113+
run: |
114+
name=dev
115+
echo $GITHUB_REF
116+
if [[ $GITHUB_REF == refs/tags/v* ]]; then
117+
name=${GITHUB_REF:10}
118+
fi
119+
echo "tag=${name//v}" >> "$GITHUB_OUTPUT"
120+
- name: Build Docker Images
121+
shell: bash
122+
run: make docker-build VERSION=${{ steps.tagname.outputs.tag }}
123+
- name: Save Docker Images
124+
shell: bash
125+
run: make docker-save VERSION=${{ steps.tagname.outputs.tag }}
126+
- uses: actions/upload-artifact@v3
127+
with:
128+
name: docker
129+
path: images.tar
130+
publish:
131+
name: Publish Archive
132+
needs: [dist-binaries, dist-lambda, dist-docker]
133+
runs-on: ubuntu-latest
134+
steps:
135+
- name: Checkout sources
136+
uses: actions/checkout@v3
137+
- name: Download artifacts
138+
uses: actions/download-artifact@v3
139+
- name: List binaries
140+
run: ls -lah bins-*
141+
- name: Get tag name
142+
id: tagname
143+
run: |
144+
name=dev
145+
echo $GITHUB_REF
146+
if [[ $GITHUB_REF == refs/tags/v* ]]; then
147+
name=${GITHUB_REF:10}
148+
fi
149+
echo "tagname=${name}" >> "$GITHUB_OUTPUT"
150+
echo "tag=${name//v}" >> "$GITHUB_OUTPUT"
151+
- name: Build archive
152+
shell: bash
153+
run: |
154+
set -ex
155+
rm -rf tmp
156+
mkdir tmp
157+
mkdir dist
158+
for dir in bins-*;
159+
do
160+
platform=${dir#"bins-"}
161+
pkgname=$PROJECT_NAME-${{ steps.tagname.outputs.tag }}-$platform
162+
ls -lah $dir
163+
chmod +x $dir/*
164+
mkdir tmp/$pkgname
165+
mv $dir/* tmp/$pkgname
166+
if [[ $platform =~ "windows" ]]; then
167+
(cd tmp && zip -r ../dist/$pkgname.zip $pkgname)
168+
else
169+
tar czf dist/$pkgname.tar.gz -C tmp $pkgname
170+
fi
171+
done
172+
- name: Add scripts to archive
173+
shell: bash
174+
run: |
175+
pkgname=$PROJECT_NAME-${{ steps.tagname.outputs.tag }}-scripts
176+
tar czf dist/$pkgname.tar.gz scripts
177+
- name: Release archive
178+
uses: svenstaro/upload-release-action@v2
179+
with:
180+
repo_token: ${{ secrets.GITHUB_TOKEN }}
181+
file: dist/*
182+
file_glob: true
183+
tag: ${{ steps.tagname.outputs.tagname }}
184+
overwrite: true
185+
publish-docker:
186+
name: Publish Docker Images
187+
needs: [dist-binaries, dist-lambda, dist-docker]
188+
runs-on: ubuntu-latest
189+
steps:
190+
- name: Checkout sources
191+
uses: actions/checkout@v3
192+
- name: Download artifacts
193+
uses: actions/download-artifact@v3
194+
with:
195+
name: docker
196+
- name: Load Docker Images
197+
shell: bash
198+
run: make docker-load
199+
- name: List Docker Images
200+
shell: bash
201+
run: docker images | grep hog
202+
- name: Get tag name
203+
id: tagname
204+
run: |
205+
name=dev
206+
echo $GITHUB_REF
207+
if [[ $GITHUB_REF == refs/tags/v* ]]; then
208+
name=${GITHUB_REF:10}
209+
fi
210+
echo "tag=${name//v}" >> "$GITHUB_OUTPUT"
211+
- name: Login to Docker Hub
212+
uses: docker/login-action@v3
213+
with:
214+
username: wetfeet2000
215+
password: ${{ secrets.DOCKER_PASSWORD }}
216+
- name: Publish Docker Images
217+
run: make docker-publish VERSION=${{ steps.tagname.outputs.tag }}

.github/workflows/testing.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Testing
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
7+
env:
8+
CARGO_TERM_COLOR: always
9+
10+
jobs:
11+
lint:
12+
name: Lint
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Compile Check
17+
run: cargo check
18+
- name: Format check
19+
run: cargo fmt --all --check
20+
- name: Lint
21+
run: cargo clippy
22+
test:
23+
name: Test
24+
needs: lint
25+
runs-on: ${{ matrix.os }}
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
build: [x86_64-linux, x86_64-linux-musl, x86_64-macos, x86_64-windows]
30+
include:
31+
- build: x86_64-linux
32+
os: ubuntu-latest
33+
rust: stable
34+
target: x86_64-unknown-linux-gnu
35+
cross: false
36+
- build: x86_64-linux-musl
37+
os: ubuntu-latest
38+
rust: stable
39+
target: x86_64-unknown-linux-musl
40+
cross: true
41+
- build: x86_64-macos
42+
os: macos-latest
43+
rust: stable
44+
target: x86_64-apple-darwin
45+
cross: false
46+
# - build: aarch64-macos
47+
# os: macos-13-xlarge
48+
# rust: stable
49+
# target: aarch64-apple-darwin
50+
# cross: false
51+
- build: x86_64-windows
52+
os: windows-2019
53+
rust: stable
54+
target: x86_64-pc-windows-msvc
55+
cross: false
56+
steps:
57+
- name: Checkout sources
58+
uses: actions/checkout@v3
59+
- name: Install ${{ matrix.rust }}-${{ matrix.target }} toolchain
60+
uses: actions-rs/toolchain@v1
61+
with:
62+
profile: minimal
63+
toolchain: ${{ matrix.rust }}
64+
target: ${{ matrix.target }}
65+
override: true
66+
- name: Test
67+
uses: actions-rs/cargo@v1
68+
with:
69+
use-cross: ${{ matrix.cross }}
70+
command: test
71+
args: --release --target ${{ matrix.target }} --verbose

.travis.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

Dockerfile

Lines changed: 0 additions & 16 deletions
This file was deleted.

Dockerfile.build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM rust:latest
2+
RUN mkdir -p /build
3+
WORKDIR /build
4+
COPY . /build/
5+
RUN cargo build --release

Dockerfile.hog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM rust-builder as builder
2+
FROM debian:bookworm-slim
3+
ARG HOG="choctaw"
4+
ENV HOG_BIN="${HOG}_hog"
5+
COPY --from=builder /build/target/release/$HOG_BIN /usr/local/bin/
6+
ENTRYPOINT /usr/local/bin/$HOG_BIN

Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
null:
2+
@:
3+
4+
docker-build: check-version
5+
@echo Building Rusty Hogs version: $(VERSION)
6+
docker build --tag rust-builder -f Dockerfile.build .
7+
docker build --tag wetfeet2000/ankamali_hog:$(VERSION) --build-arg HOG=ankamali -f Dockerfile.hog .
8+
docker build --tag wetfeet2000/berkshire_hog:$(VERSION) --build-arg HOG=berkshire -f Dockerfile.hog .
9+
docker build --tag wetfeet2000/choctaw_hog:$(VERSION) --build-arg HOG=choctaw -f Dockerfile.hog .
10+
docker build --tag wetfeet2000/duroc_hog:$(VERSION) --build-arg HOG=duroc -f Dockerfile.hog .
11+
docker build --tag wetfeet2000/essex_hog:$(VERSION) --build-arg HOG=essex -f Dockerfile.hog .
12+
docker build --tag wetfeet2000/gottingen_hog:$(VERSION) --build-arg HOG=gottingen -f Dockerfile.hog .
13+
docker build --tag wetfeet2000/hante_hog:$(VERSION) --build-arg HOG=hante -f Dockerfile.hog .
14+
15+
docker-save: check-version
16+
docker image save -o images.tar \
17+
wetfeet2000/ankamali_hog:$(VERSION) \
18+
wetfeet2000/berkshire_hog:$(VERSION) \
19+
wetfeet2000/choctaw_hog:$(VERSION) \
20+
wetfeet2000/duroc_hog:$(VERSION) \
21+
wetfeet2000/essex_hog:$(VERSION) \
22+
wetfeet2000/gottingen_hog:$(VERSION) \
23+
wetfeet2000/hante_hog:$(VERSION)
24+
25+
docker-load:
26+
docker load -i images.tar
27+
28+
docker-publish: check-version
29+
docker push wetfeet2000/ankamali_hog:$(VERSION)
30+
docker push wetfeet2000/berkshire_hog:$(VERSION)
31+
docker push wetfeet2000/choctaw_hog:$(VERSION)
32+
docker push wetfeet2000/duroc_hog:$(VERSION)
33+
docker push wetfeet2000/essex_hog:$(VERSION)
34+
docker push wetfeet2000/gottingen_hog:$(VERSION)
35+
docker push wetfeet2000/hante_hog:$(VERSION)
36+
37+
check-version:
38+
@if test ! $(VERSION); then echo "VERSION is undefined"; exit 1; fi

build_docker.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)