-
Notifications
You must be signed in to change notification settings - Fork 9
123 lines (107 loc) · 3.81 KB
/
releases.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
name: Prepare release
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-*'
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Retrieve cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-ci-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: cargo build --release
uses: actions-rs/cargo@v1
with:
command: build
args: --release
env:
TARGET: x86_64-unknown-linux-musl
- name: Create checksum
run: |
sha256sum target/release/dfw > target/release/dfw.sha256
- name: Identify if tag is a prerelease
id: tag
run: |
if [[ "${{ github.ref }}" =~ ^refs/tags/(.+)$ ]]; then
echo "::set-output name=value::${BASH_REMATCH[1]}"
else
echo "::error ::Expected a tag"
exit 1
fi
if [[ "${{ github.ref }}" =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::set-output name=is-prerelease::false"
else
echo "::set-output name=is-prerelease::true"
fi
- name: Extract current changelog
id: changelog
run:
|
changelog="$(hack/extract-current-changelog.py CHANGELOG.md)"
# https://github.community/t/set-output-truncates-multiline-strings/16852/3
changelog="${changelog//'%'/'%25'}"
changelog="${changelog//$'\n'/'%0A'}"
changelog="${changelog//$'\r'/'%0D'}"
echo "::set-output name=value::$changelog"
- name: Prepare release
id: prepare-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: v${{ github.ref }}
draft: true
prerelease: ${{ steps.tag.outputs.is-prerelease }}
body: |
# Summary
TODO!
## Changes
${{ steps.changelog.outputs.value }}
## Installation
While you can use Cargo to install `dfw` as a binary, using the Docker image is the preferred way to go, especially if you don't want to install Rust and Cargo on your host:
```console
$ docker pull pitkley/dfw:${{ steps.tag.outputs.value }}
$ docker run -d \
--name=dfw \
--restart=unless-stopped \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /path/to/your/config:/config \
--net host --cap-add=NET_ADMIN \
pitkley/dfw:${{ steps.tag.outputs.value }} --config-path /config
```
This will download a lightweight image, coming in at around 20 MB, and subsequently run it using your configuration.
The image supports multiple architectures: `amd64`, `arm64`, `armv7` (specifically `armhf`).
- name: Upload static DFW binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.prepare-release.outputs.upload_url }}
asset_path: target/release/dfw
asset_name: dfw-x86_64-unknown-linux-musl
asset_content_type: application/octet-stream
- name: Upload static DFW binary checksum
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.prepare-release.outputs.upload_url }}
asset_path: target/release/dfw.sha256
asset_name: dfw-x86_64-unknown-linux-musl.sha256
asset_content_type: application/octet-stream