Skip to content

Commit 2cfc0aa

Browse files
authored
add cd (#417)
Signed-off-by: MarcoIeni <11428655+MarcoIeni@users.noreply.github.com>
1 parent 9d72205 commit 2cfc0aa

File tree

2 files changed

+72
-9
lines changed

2 files changed

+72
-9
lines changed

.github/workflows/cd.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Continuous Deployment
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
publish:
10+
name: Publishing for ${{ matrix.job.os }}
11+
runs-on: ${{ matrix.job.os }}
12+
strategy:
13+
matrix:
14+
job:
15+
- { os: macos-latest, target: x86_64-apple-darwin, use-cross: false }
16+
- { os: windows-latest, target: x86_64-pc-windows-msvc, use-cross: false }
17+
- { os: ubuntu-latest , target: x86_64-unknown-linux-gnu, use-cross: false }
18+
- { os: ubuntu-latest, target: x86_64-unknown-linux-musl, use-cross: true }
19+
- { os: ubuntu-latest, target: i686-unknown-linux-gnu, use-cross: true }
20+
- { os: ubuntu-latest, target: arm-unknown-linux-gnueabihf, use-cross: true }
21+
- { os: ubuntu-latest, target: aarch64-unknown-linux-gnu, use-cross: true }
22+
23+
steps:
24+
- name: Installing Rust toolchain
25+
uses: actions-rs/toolchain@v1
26+
with:
27+
toolchain: stable
28+
profile: minimal
29+
override: true
30+
- name: Checkout repository
31+
uses: actions/checkout@v2
32+
- name: Cargo build
33+
uses: actions-rs/cargo@v1
34+
with:
35+
command: build
36+
use-cross: ${{ matrix.job.use-cross }}
37+
args: --release --target ${{ matrix.job.target }}
38+
39+
- name: Install required dependencies
40+
shell: bash
41+
run: |
42+
if [[ ${{ matrix.job.target }} == arm-unknown-linux-gnueabihf ]]; then
43+
sudo apt update
44+
sudo apt-get install -y binutils-arm-linux-gnueabihf
45+
fi
46+
if [[ ${{ matrix.job.target }} == aarch64-unknown-linux-gnu ]]; then
47+
sudo apt update
48+
sudo apt-get install -y binutils-aarch64-linux-gnu
49+
fi
50+
51+
- name: Packaging final binary
52+
shell: bash
53+
env:
54+
TARGET: ${{ matrix.job.target }}
55+
PROJECT_NAME: delta
56+
PACKAGE_NAME: git-delta
57+
OS_NAME: ${{ matrix.job.os }}
58+
run: ./etc/ci/before_deploy.sh
59+
60+
- name: Releasing assets
61+
uses: softprops/action-gh-release@v1
62+
with:
63+
files: |
64+
delta-*-${{ matrix.job.target }}.*
65+
git-delta*.deb
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

etc/ci/before_deploy.sh

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33

44
set -ex
55

6-
build() {
7-
cargo build --target "$TARGET" --release --verbose
8-
}
9-
106
pack() {
117
local tempdir
128
local out_dir
@@ -15,7 +11,7 @@ pack() {
1511

1612
tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)
1713
out_dir=$(pwd)
18-
package_name="$PROJECT_NAME-$TRAVIS_TAG-$TARGET"
14+
package_name="$PROJECT_NAME-${GITHUB_REF/refs\/tags\//}-$TARGET"
1915

2016
if [[ $TARGET == "arm-unknown-linux-gnueabihf" ]]; then
2117
gcc_prefix="arm-linux-gnueabihf-"
@@ -30,7 +26,7 @@ pack() {
3026

3127
# copying the main binary
3228
cp "target/$TARGET/release/$PROJECT_NAME" "$tempdir/$package_name/"
33-
if [ "$TRAVIS_OS_NAME" != windows ]; then
29+
if [ "$OS_NAME" != windows-latest ]; then
3430
"${gcc_prefix}"strip "$tempdir/$package_name/$PROJECT_NAME"
3531
fi
3632

@@ -40,7 +36,7 @@ pack() {
4036

4137
# archiving
4238
pushd "$tempdir"
43-
if [ "$TRAVIS_OS_NAME" = windows ]; then
39+
if [ "$OS_NAME" = windows-latest ]; then
4440
7z a "$out_dir/$package_name.zip" "$package_name"/*
4541
else
4642
tar czf "$out_dir/$package_name.tar.gz" "$package_name"/*
@@ -89,7 +85,8 @@ make_deb() {
8985
return 0
9086
;;
9187
esac
92-
version=${TRAVIS_TAG#v}
88+
version=${GITHUB_REF/refs\/tags\//}
89+
9390
if [[ $TARGET = *musl* ]]; then
9491
dpkgname=$PACKAGE_NAME-musl
9592
conflictname=$PROJECT_NAME
@@ -171,7 +168,6 @@ EOF
171168

172169

173170
main() {
174-
build
175171
pack
176172
if [[ $TARGET = *linux* ]]; then
177173
make_deb

0 commit comments

Comments
 (0)