mirror of
https://github.com/aramperes/onetun.git
synced 2025-09-09 06:18:31 -04:00
Add GitHub actions
This commit is contained in:
parent
b4317dad1a
commit
b28a5b0a6b
4 changed files with 238 additions and 0 deletions
6
.github/ci/macos-install-packages
vendored
Executable file
6
.github/ci/macos-install-packages
vendored
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
brew install asciidoctor
|
||||||
|
|
||||||
|
brew install openssl@1.1
|
||||||
|
cp /usr/local/opt/openssl@1.1/lib/pkgconfig/*.pc /usr/local/lib/pkgconfig/
|
6
.github/ci/ubuntu-install-packages
vendored
Executable file
6
.github/ci/ubuntu-install-packages
vendored
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y --no-install-recommends \
|
||||||
|
asciidoctor \
|
||||||
|
zsh xz-utils liblz4-tool musl-tools libssl-dev openssl pkg-config
|
104
.github/workflows/build.yml
vendored
Normal file
104
.github/workflows/build.yml
vendored
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
name: Build
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
name: Check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
rust:
|
||||||
|
- stable
|
||||||
|
- 1.55.0
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ matrix.rust }}
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Run cargo check
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: check
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Test Suite
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
rust:
|
||||||
|
- stable
|
||||||
|
- 1.55.0
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ matrix.rust }}
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Run cargo test
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
|
||||||
|
fmt:
|
||||||
|
name: Rustfmt
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
rust:
|
||||||
|
- stable
|
||||||
|
- 1.55.0
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ matrix.rust }}
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Install rustfmt
|
||||||
|
run: rustup component add rustfmt
|
||||||
|
|
||||||
|
- name: Run cargo fmt
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: fmt
|
||||||
|
args: --all -- --check
|
||||||
|
|
||||||
|
clippy:
|
||||||
|
name: Clippy
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
rust:
|
||||||
|
- stable
|
||||||
|
- 1.55.0
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ matrix.rust }}
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Install clippy
|
||||||
|
run: rustup component add clippy
|
||||||
|
|
||||||
|
- name: Run cargo clippy
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: clippy
|
||||||
|
args: -- -D warnings
|
122
.github/workflows/release.yml
vendored
Normal file
122
.github/workflows/release.yml
vendored
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
name: release
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||||
|
jobs:
|
||||||
|
create-release:
|
||||||
|
name: create-release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Create artifacts directory
|
||||||
|
run: mkdir artifacts
|
||||||
|
|
||||||
|
- name: Get the release version from the tag
|
||||||
|
if: env.VERSION == ''
|
||||||
|
run: |
|
||||||
|
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
||||||
|
echo "version is: ${{ env.VERSION }}"
|
||||||
|
- name: Create GitHub release
|
||||||
|
id: release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ env.VERSION }}
|
||||||
|
release_name: ${{ env.VERSION }}
|
||||||
|
|
||||||
|
- name: Save release upload URL to artifact
|
||||||
|
run: echo "${{ steps.release.outputs.upload_url }}" > artifacts/release-upload-url
|
||||||
|
|
||||||
|
- name: Save version number to artifact
|
||||||
|
run: echo "${{ env.VERSION }}" > artifacts/release-version
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v1
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: artifacts
|
||||||
|
|
||||||
|
build-release:
|
||||||
|
name: build-release
|
||||||
|
needs: [ 'create-release' ]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
env:
|
||||||
|
# Emit backtraces on panics.
|
||||||
|
RUST_BACKTRACE: 1
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
build: [ linux-amd64, macos-intel, windows ]
|
||||||
|
include:
|
||||||
|
- build: linux-amd64
|
||||||
|
os: ubuntu-18.04
|
||||||
|
rust: stable
|
||||||
|
target: x86_64-unknown-linux-musl
|
||||||
|
- build: macos-intel
|
||||||
|
os: macos-latest
|
||||||
|
rust: stable
|
||||||
|
target: x86_64-apple-darwin
|
||||||
|
- build: windows
|
||||||
|
os: windows-2019
|
||||||
|
rust: stable
|
||||||
|
target: x86_64-pc-windows-msvc
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Install packages (Ubuntu)
|
||||||
|
if: matrix.os == 'ubuntu-18.04'
|
||||||
|
run: |
|
||||||
|
.github/ci/ubuntu-install-packages
|
||||||
|
- name: Install packages (macOS)
|
||||||
|
if: matrix.os == 'macos-latest'
|
||||||
|
run: |
|
||||||
|
.github/ci/macos-install-packages
|
||||||
|
- name: Install Rust
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ matrix.rust }}
|
||||||
|
profile: minimal
|
||||||
|
override: true
|
||||||
|
target: ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Get release download URL
|
||||||
|
uses: actions/download-artifact@v1
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: artifacts
|
||||||
|
|
||||||
|
- name: Set release upload URL
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
release_upload_url="$(cat artifacts/release-upload-url)"
|
||||||
|
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV
|
||||||
|
echo "release upload url: $release_upload_url"
|
||||||
|
|
||||||
|
- name: Build onetun binary
|
||||||
|
run: cargo build --release
|
||||||
|
|
||||||
|
- name: Prepare onetun binary
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir -p ci/assets
|
||||||
|
if [ "${{ matrix.build }}" = "windows" ]; then
|
||||||
|
cp "target/release/onetun.exe" "ci/assets/onetun.exe"
|
||||||
|
echo "ASSET=onetun.exe" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
cp "target/release/onetun" "ci/assets/onetun-${{ matrix.build }}"
|
||||||
|
echo "ASSET=onetun-${{ matrix.build }}" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Upload release archive
|
||||||
|
uses: actions/upload-release-asset@v1.0.1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
|
||||||
|
asset_path: ci/assets/${{ env.ASSET }}
|
||||||
|
asset_name: ${{ env.ASSET }}
|
||||||
|
asset_content_type: application/octet-stream
|
Loading…
Add table
Add a link
Reference in a new issue