-
Notifications
You must be signed in to change notification settings - Fork 20
126 lines (122 loc) · 4.13 KB
/
cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Continuous Deployment
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
jobs:
generate-changelog:
name: Generate changelog
runs-on: ubuntu-20.04
outputs:
release_body: ${{ steps.release.outputs.release_body }}
steps:
- name: Checkout
uses: actions/checkout@main
with:
fetch-depth: 0
- name: Generate a changelog
uses: orhun/git-cliff-action@v1
id: git-cliff
with:
config: cliff.toml
args: -vv --latest --strip header
env:
OUTPUT: CHANGES.md
- name: Set the release body
id: release
shell: bash
run: |
r=$(cat ${{ steps.git-cliff.outputs.changelog }})
r="$(printf "$r" | tail -n +3)"
r="${r//'%'/'%25'}"
r="${r//$'\n'/'%0A'}"
r="${r//$'\r'/'%0D'}"
echo "::set-output name=release_body::$r"
publish-github:
name: Publish on GitHub
needs: generate-changelog
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [linux64-gnu, linux64-musl, linux-armv7-musl, macos-x64]
include:
- BUILD: linux64-gnu
OS: ubuntu-20.04
TOOLCHAIN: stable
TARGET: x86_64-unknown-linux-gnu
- BUILD: linux64-musl
OS: ubuntu-20.04
TOOLCHAIN: stable
TARGET: x86_64-unknown-linux-musl
CROSS: true
- BUILD: macos-x64
OS: macos-11
TOOLCHAIN: stable
TARGET: x86_64-apple-darwin
- BUILD: linux-armv7-musl
OS: ubuntu-20.04
TOOLCHAIN: stable
TARGET: armv7-unknown-linux-musleabihf
CROSS: true
steps:
- name: Checkout
uses: actions/checkout@main
- name: Set the release version
shell: bash
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.TOOLCHAIN }}
target: ${{ matrix.TARGET }}
override: true
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.CROSS }}
command: build
args: --release --target ${{ matrix.TARGET }} --bins --examples
- name: Prepare release assets
shell: bash
run: |
mkdir -p release/examples
mkdir -p release/bin
cp {LICENSE*,COPYRIGHT,README.md,CHANGELOG.md} release/
cp -r doc release/doc
cp target/${{ matrix.TARGET }}/release/{dtnd,dtntrigger,dtnsend,dtnrecv,dtnquery} release/bin
cp target/${{ matrix.TARGET }}/release/examples/{dtnping,dtnecho2} release/examples
mv release/ dtn7-${{ env.RELEASE_VERSION }}/
- name: Create release artifacts
shell: bash
run: |
tar -czvf dtn7-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz \
dtn7-${{ env.RELEASE_VERSION }}/
shasum -a 512 dtn7-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz \
> dtn7-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz.sha512
- name: Upload the release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dtn7-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}*
file_glob: true
overwrite: true
tag: ${{ github.ref }}
release_name: "Release v${{ env.RELEASE_VERSION }}"
body: "${{ needs.generate-changelog.outputs.release_body }}"
publish-crates-io:
name: Publish on crates.io
needs: publish-github
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@main
- name: Set the release version
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
- name: Publish the crate
uses: actions-rs/cargo@v1
with:
command: publish
args: |
--allow-dirty --manifest-path core/dtn7/Cargo.toml
--token ${{ secrets.CARGO_TOKEN }}