-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): add binary build and release workflow (#77)
This adds a workflow (or actually several parallel ones) that gets triggered for a new tag. It builds binaries for several different platforms, creates a release and attaches them as downloads. I wasn't able to make this work for arm64 (because of ring) therefore I commented that part for now. Fix #59
- Loading branch information
Showing
2 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
name: Deploy binaries and create release | ||
on: | ||
release: | ||
types: | ||
- published | ||
env: | ||
CARGO_TERM_COLOR: always | ||
RUST_BACKTRACE: 1 | ||
|
||
jobs: | ||
github_build: | ||
name: Build release binaries | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
include: | ||
- target: x86_64-unknown-linux-gnu | ||
os: ubuntu-latest | ||
name: prometheus_wireguard_exporter-x86_64-unknown-linux-gnu | ||
|
||
- target: x86_64-unknown-linux-musl | ||
os: ubuntu-latest | ||
name: prometheus_wireguard_exporter-x86_64-unknown-linux-musl | ||
|
||
- target: i686-unknown-linux-musl | ||
os: ubuntu-latest | ||
name: prometheus_wireguard_exporter-i686-unknown-linux-musl | ||
|
||
- target: aarch64-unknown-linux-musl | ||
os: ubuntu-latest | ||
name: prometheus_wireguard_exporter-aarch64-unknown-linux-musl | ||
|
||
- target: arm-unknown-linux-musleabi | ||
os: ubuntu-latest | ||
name: prometheus_wireguard_exporter-arm-unknown-linux-musleabi | ||
|
||
# - target: armv7-unknown-linux-musleabi | ||
# os: ubuntu-latest | ||
# name: prometheus_wireguard_exporter-armv7-unknown-linux-musleabi | ||
|
||
- target: x86_64-apple-darwin | ||
os: macOS-latest | ||
name: prometheus_wireguard_exporter-x86_64-apple-darwin | ||
|
||
# - target: aarch64-apple-darwin | ||
# os: macOS-latest | ||
# name: prometheus_wireguard_exporter-aarch64-apple-darwin | ||
|
||
- target: x86_64-pc-windows-msvc | ||
os: windows-latest | ||
name: prometheus_wireguard_exporter-x86_64-pc-windows-msvc.exe | ||
|
||
- target: i686-pc-windows-msvc | ||
os: windows-latest | ||
name: prometheus_wireguard_exporter-i686-pc-windows-msvc.exe | ||
|
||
# - target: aarch64-pc-windows-msvc | ||
# os: windows-latest | ||
# name: prometheus_wireguard_exporter-aarch64-pc-windows-msvc.exe | ||
|
||
- target: x86_64-unknown-freebsd | ||
os: ubuntu-latest | ||
name: prometheus_wireguard_exporter-x86_64-unknown-freebsd | ||
|
||
runs-on: ${{ matrix.os }} | ||
continue-on-error: false | ||
steps: | ||
- name: Setup | Checkout | ||
uses: actions/[email protected] | ||
|
||
- name: Setup | Cache Cargo | ||
uses: actions/[email protected] | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
|
||
- name: Setup | Rust | ||
uses: actions-rs/[email protected] | ||
with: | ||
toolchain: stable | ||
override: true | ||
profile: minimal | ||
target: ${{ matrix.target }} | ||
|
||
- name: Build | Ubuntu | ||
if: matrix.os != 'macOS-latest' | ||
uses: actions-rs/[email protected] | ||
with: | ||
command: build | ||
args: --release --locked --target ${{ matrix.target }} | ||
use-cross: ${{ matrix.os == 'ubuntu-latest' }} | ||
|
||
- name: Build | macOS | ||
if: matrix.os == 'macOS-latest' | ||
uses: actions-rs/[email protected] | ||
with: | ||
command: build | ||
args: --release --locked --target ${{ matrix.target }} | ||
|
||
- name: Post Build | Prepare artifacts [Windows] | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
cd target/${{ matrix.target }}/release | ||
strip prometheus_wireguard_exporter.exe | ||
mv prometheus_wireguard_exporter.exe ../../../${{ matrix.name }} | ||
cd - | ||
- name: Post Build | Prepare artifacts [-nix] | ||
if: matrix.os != 'windows-latest' | ||
run: | | ||
cd target/${{ matrix.target }}/release | ||
strip prometheus_wireguard_exporter || true | ||
mv prometheus_wireguard_exporter ../../../${{ matrix.name }} | ||
cd - | ||
- name: Display structure of downloaded files | ||
run: ls -R | ||
|
||
- name: Deploy | Upload artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ matrix.name }} | ||
path: ${{ matrix.name }} | ||
|
||
# Create GitHub release with Rust build targets and release notes | ||
github_release: | ||
name: Create GitHub Release | ||
needs: github_build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup | Checkout | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup | Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "^1.15.7" | ||
|
||
- name: Setup | Download Artifacts | ||
uses: actions/download-artifact@v2 | ||
|
||
- name: Display structure of downloaded files | ||
run: ls -R | ||
|
||
- name: Setup | Create Checksum files | ||
run: | | ||
for DIR in prometheus_wireguard_exporter-* | ||
do | ||
pushd "$DIR" || continue | ||
FILE="$(echo prometheus_wireguard_exporter-*)" | ||
sha256sum "$FILE" > "$FILE.sha256" | ||
popd || exit | ||
done | ||
# - name: Setup | Release notes | ||
# run: | | ||
# GO111MODULE=on go get github.com/git-chglog/git-chglog/cmd/[email protected] | ||
# git-chglog -c .github/chglog/release.yml $(git describe --tags) > RELEASE.md | ||
|
||
- name: Build | Publish binaries | ||
uses: alexellis/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
asset_paths: '["prometheus_wireguard_exporter-*/prometheus_wireguard_exporter-*"]' | ||
|
||
# Publish prometheus_wireguard_exporter to Crates.io | ||
# cargo_publish: | ||
# name: Publish Cargo Package | ||
# runs-on: ubuntu-latest | ||
# needs: github_release | ||
# steps: | ||
# - name: Setup | Checkout | ||
# uses: actions/[email protected] | ||
|
||
# - name: Setup | Rust | ||
# uses: actions-rs/[email protected] | ||
# with: | ||
# toolchain: stable | ||
# profile: minimal | ||
# override: true | ||
|
||
# - name: Build | Publish | ||
# run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }} |