Skip to content

Commit

Permalink
Add ci and auto release
Browse files Browse the repository at this point in the history
  • Loading branch information
Ma233 committed Jul 8, 2024
1 parent 217d928 commit 50d9588
Show file tree
Hide file tree
Showing 6 changed files with 340 additions and 57 deletions.
55 changes: 0 additions & 55 deletions .github/workflows/build.yml

This file was deleted.

112 changes: 112 additions & 0 deletions .github/workflows/build_then_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Build then release

on:
push:
tags:
- "v*"
branches:
- "master"

env:
CARGO_TERM_COLOR: always

jobs:
gen_version:
name: Generate version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.generated-tag.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get latest tag
id: get-latest-tag
run: |
echo "tag=`gh release list -L 1 | cut -f 1`" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Bump version
id: generated-tag
uses: actions/github-script@v6
with:
script: |
if (context.ref.startsWith("refs/tags/")) {
let tag = context.ref.replace("refs/tags/", "");
core.setOutput('tag', tag);
console.log(`This event pushed a tag ${tag}, return directly.`)
return
}
console.log('Use default tag "prerelease".')
core.setOutput('tag', 'prerelease');
build:
needs: gen_version
name: Build
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- { target: x86_64-apple-darwin, runner: macos-latest }
- { target: aarch64-apple-darwin, runner: macos-latest }
- { target: x86_64-unknown-linux-musl, runner: ubuntu-latest }
- { target: aarch64-unknown-linux-musl, runner: ubuntu-latest }
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup protoc
uses: arduino/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install musl-tools
if: matrix.runner == 'ubuntu-latest'
run: sudo apt update && sudo apt install -y musl-tools
- name: Add target
run: rustup target add ${{ matrix.target }}
- name: Setup rust toolchain
run: rustup show
- uses: Swatinem/rust-cache@v2
with:
shared-key: build-then-release-${{ matrix.target }}-v1
- name: Build
run: |
cargo build --release --target ${{ matrix.target }}
zip -j pproxy-${{ needs.gen_version.outputs.version }}-${{ matrix.target }}.zip ./target/${{ matrix.target }}/release/pproxy
- uses: actions/upload-artifact@v4
name: Upload artifacts
with:
name: pproxy-${{ needs.gen_version.outputs.version }}-${{ matrix.target }}
path: pproxy-${{ needs.gen_version.outputs.version }}-${{ matrix.target }}.zip
retention-days: 1

release:
needs: [gen_version, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Generate changelog
uses: orhun/git-cliff-action@v3
id: git-cliff
with:
config: cliff.toml
args: "-vv --strip header ${{ needs.gen_version.outputs.version == 'prerelease' && '--unreleased' || '--latest' }}"
- uses: actions/download-artifact@v3
- name: Display fetched artifacts
run: ls -R
- uses: softprops/[email protected]
name: Emit a Github Release
with:
token: "${{ secrets.GITHUB_TOKEN }}"
body: "${{ steps.git-cliff.outputs.content }}"
tag_name: ${{ needs.gen_version.outputs.version }}
prerelease: ${{ needs.gen_version.outputs.version == 'prerelease' }}
title: ${{ needs.gen_version.outputs.version }}
files: |
LICENSE
pproxy-${{ needs.gen_version.outputs.version }}-x86_64-apple-darwin/*.zip
pproxy-${{ needs.gen_version.outputs.version }}-aarch64-apple-darwin/*.zip
pproxy-${{ needs.gen_version.outputs.version }}-x86_64-unknown-linux-musl/*.zip
pproxy-${{ needs.gen_version.outputs.version }}-aarch64-unknown-linux-musl/*.zip
43 changes: 43 additions & 0 deletions .github/workflows/check_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Check and test

on:
push:
branches:
- master
pull_request:
branches:
- master

env:
CARGO_TERM_COLOR: always

jobs:
test:
name: Check and test
strategy:
matrix:
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup protoc
uses: arduino/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup rust toolchain
run: rustup show
- name: Install nextest
uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
with:
shared-key: check-and-test-${{ matrix.platform }}-v1
- name: Check code format
run: cargo fmt -- --check
- name: Check the package for errors
run: cargo check --all
- name: Lint rust sources
run: cargo clippy --all-targets --all-features --tests --benches -- -D warnings
- name: Execute rust tests
run: cargo nextest run --all-features
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ http-body-util = "0.1.1"
httparse = "1.8.0"
hyper = { version = "1.3.1", features = ["server", "http1"] }
hyper-util = { version = "0.1.5", features = ["tokio"] }
litep2p = { git = "https://github.com/Ma233/litep2p.git", branch = "pproxy-patch" }
litep2p = { git = "https://github.com/Ma233/litep2p.git", rev = "144d81c" }
# Do not upgrade multiaddr, see: https://github.com/paritytech/litep2p/pull/91
multiaddr = "0.17.1"
percent-encoding = "2.3.1"
prost = "0.12.4"
prost = "0.12.6"
thiserror = "1.0.60"
tokio = { version = "1.37.0", features = ["rt-multi-thread"] }
tokio-util = "0.7.11"
Expand All @@ -30,3 +30,7 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

[build-dependencies]
tonic-build = "0.11.0"

[[bin]]
name = "pproxy"
path = "src/main.rs"
Loading

0 comments on commit 50d9588

Please sign in to comment.