Skip to content

Commit eb7a960

Browse files
authored
Merge pull request #3 from denislituev/add_github_actions
Add GitHub Actions
2 parents 1334e8e + 816bebe commit eb7a960

18 files changed

Lines changed: 600 additions & 616 deletions

File tree

.cargo/audit.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[advisories]
2+
ignore = ["RUSTSEC-2023-0071"] # rsa, no safe upgrade is available

.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[net]
2+
git-fetch-with-cli = true

.cargo/deny.toml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[graph]
2+
targets = []
3+
all-features = false
4+
no-default-features = false
5+
exclude-dev = true
6+
7+
[output]
8+
feature-depth = 1
9+
10+
[licenses]
11+
allow = [
12+
"Apache-2.0",
13+
"MIT",
14+
"Unicode-3.0",
15+
]
16+
17+
confidence-threshold = 0.8
18+
exceptions = []
19+
20+
[licenses.private]
21+
ignore = true
22+
registries = []
23+
24+
[bans]
25+
multiple-versions = "allow"
26+
wildcards = "allow"
27+
highlight = "all"
28+
workspace-default-features = "allow"
29+
external-default-features = "allow"
30+
allow = []
31+
deny = []
32+
skip = []
33+
skip-tree = []
34+
35+
[sources]
36+
unknown-registry = "warn"
37+
unknown-git = "warn"
38+
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
39+
allow-git = []
40+
41+
[sources.allow-org]
42+
github = []
43+
gitlab = []
44+
bitbucket = []
45+
46+
[advisories]
47+
ignore = []

.github/workflows/ci.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [main, master]
6+
push:
7+
branches: [main, master]
8+
9+
concurrency:
10+
group: ci-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
env:
14+
CARGO_TERM_COLOR: always
15+
16+
jobs:
17+
lint:
18+
name: Lint
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Install Rust toolchain
24+
uses: dtolnay/rust-toolchain@stable
25+
with:
26+
components: rustfmt, clippy
27+
28+
- name: Cache cargo and build
29+
uses: Swatinem/rust-cache@v2
30+
31+
- name: Run rustfmt
32+
run: cargo fmt --all -- --check
33+
34+
- name: Run clippy
35+
run: cargo clippy --all-targets --all-features -- -D warnings
36+
37+
test:
38+
name: Test
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Install Rust toolchain
44+
uses: dtolnay/rust-toolchain@stable
45+
46+
- name: Cache cargo and build
47+
uses: Swatinem/rust-cache@v2
48+
49+
- name: Run tests
50+
run: cargo test --all-features --verbose --locked
51+
52+
build:
53+
name: Build (release)
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- name: Install Rust toolchain
59+
uses: dtolnay/rust-toolchain@stable
60+
61+
- name: Cache cargo and build
62+
uses: Swatinem/rust-cache@v2
63+
64+
- name: Build release
65+
run: cargo build --release --all-features --locked
66+
67+
- name: Upload binary
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: tiny-proxy-linux
71+
path: target/release/tiny-proxy
72+
if-no-files-found: error

.github/workflows/pr-check.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: PR Check
2+
3+
on:
4+
pull_request:
5+
branches: [main, master]
6+
workflow_dispatch:
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
quick-check:
13+
name: Quick Quality Check
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Install Rust toolchain
19+
uses: dtolnay/rust-toolchain@stable
20+
with:
21+
components: rustfmt, clippy
22+
23+
- name: Cache cargo and build
24+
uses: Swatinem/rust-cache@v2
25+
26+
- name: Check formatting
27+
run: cargo fmt --all -- --check
28+
29+
- name: Run Clippy
30+
run: cargo clippy --all-targets --all-features -- -D warnings
31+
32+
- name: Quick build check
33+
run: cargo check --all-features --locked
34+
35+
- name: Check documentation
36+
run: cargo doc --no-deps --all-features --document-private-items
37+
38+
security-audit:
39+
name: Security Audit
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
44+
- name: Install Rust toolchain
45+
uses: dtolnay/rust-toolchain@stable
46+
47+
- name: Cache cargo and build
48+
uses: Swatinem/rust-cache@v2
49+
50+
- name: Install cargo-audit
51+
uses: taiki-e/install-action@cargo-audit
52+
53+
- name: Run cargo audit
54+
run: cargo audit
55+
56+
license-check:
57+
name: License Check
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- name: Install Rust toolchain
63+
uses: dtolnay/rust-toolchain@stable
64+
65+
- name: Cache cargo and build
66+
uses: Swatinem/rust-cache@v2
67+
68+
- name: Install cargo-deny
69+
uses: taiki-e/install-action@cargo-deny
70+
71+
- name: Check licenses
72+
run: cargo deny check licenses

.github/workflows/release.yml

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: "Tag to release (e.g., v0.1.0)"
11+
required: true
12+
type: string
13+
14+
concurrency:
15+
group: release-${{ github.ref }}
16+
cancel-in-progress: false
17+
18+
env:
19+
CARGO_TERM_COLOR: always
20+
RUSTFLAGS: "-C strip=symbols"
21+
22+
jobs:
23+
release-build:
24+
name: Build Release Binaries
25+
runs-on: ${{ matrix.os }}
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
include:
30+
- os: ubuntu-latest
31+
target: x86_64-unknown-linux-gnu
32+
artifact: tiny-proxy-linux-amd64
33+
use-cross: false
34+
35+
- os: ubuntu-latest
36+
target: aarch64-unknown-linux-gnu
37+
artifact: tiny-proxy-linux-arm64
38+
use-cross: true
39+
40+
- os: macos-13
41+
target: x86_64-apple-darwin
42+
artifact: tiny-proxy-macos-amd64
43+
use-cross: false
44+
45+
- os: macos-14
46+
target: aarch64-apple-darwin
47+
artifact: tiny-proxy-macos-arm64
48+
use-cross: false
49+
50+
- os: windows-latest
51+
target: x86_64-pc-windows-msvc
52+
artifact: tiny-proxy-windows-amd64.exe
53+
use-cross: false
54+
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- name: Install Rust toolchain
59+
uses: dtolnay/rust-toolchain@stable
60+
with:
61+
targets: ${{ matrix.target }}
62+
63+
- name: Cache
64+
uses: Swatinem/rust-cache@v2
65+
66+
- name: Install cross
67+
if: matrix.use-cross
68+
uses: taiki-e/install-action@cross
69+
70+
- name: Build
71+
run: |
72+
if [ "${{ matrix.use-cross }}" = "true" ]; then
73+
cross build --release --target ${{ matrix.target }} --all-features --locked
74+
else
75+
cargo build --release --target ${{ matrix.target }} --all-features --locked
76+
fi
77+
shell: bash
78+
79+
- name: Prepare artifact
80+
run: |
81+
mkdir -p dist
82+
83+
BIN_PATH=target/${{ matrix.target }}/release/tiny-proxy
84+
85+
if [ "${{ runner.os }}" = "Windows" ]; then
86+
BIN_PATH="${BIN_PATH}.exe"
87+
fi
88+
89+
cp "$BIN_PATH" dist/${{ matrix.artifact }}
90+
91+
cd dist
92+
shasum -a 256 ${{ matrix.artifact }} > ${{ matrix.artifact }}.sha256
93+
shell: bash
94+
95+
- name: Upload artifact
96+
uses: actions/upload-artifact@v4
97+
with:
98+
name: ${{ matrix.artifact }}
99+
path: dist/
100+
101+
publish-crate:
102+
name: Publish to crates.io
103+
runs-on: ubuntu-latest
104+
needs: release-build
105+
steps:
106+
- uses: actions/checkout@v4
107+
108+
- name: Install Rust toolchain
109+
uses: dtolnay/rust-toolchain@stable
110+
111+
- name: Cache
112+
uses: Swatinem/rust-cache@v2
113+
114+
- name: Publish
115+
run: cargo publish --locked || echo "Already published"
116+
env:
117+
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
118+
119+
create-release:
120+
name: Create GitHub Release
121+
runs-on: ubuntu-latest
122+
needs: [release-build, publish-crate]
123+
124+
steps:
125+
- uses: actions/checkout@v4
126+
127+
- name: Download artifacts
128+
uses: actions/download-artifact@v4
129+
with:
130+
path: dist
131+
132+
- name: Get tag
133+
id: tag
134+
run: |
135+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
136+
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
137+
else
138+
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
139+
fi
140+
141+
- name: Create release notes
142+
run: |
143+
cat > release_notes.md << EOF
144+
# tiny-proxy ${{ steps.tag.outputs.tag }}
145+
146+
## Installation
147+
148+
### Linux/macOS
149+
\`\`\`bash
150+
curl -L https://github.com/${{ github.repository }}/releases/download/${{ steps.tag.outputs.tag }}/tiny-proxy-linux-amd64 -o tiny-proxy
151+
chmod +x tiny-proxy
152+
./tiny-proxy --help
153+
\`\`\`
154+
155+
### Windows
156+
Download and run:
157+
tiny-proxy-windows-amd64.exe
158+
159+
### Cargo
160+
\`\`\`bash
161+
cargo install tiny-proxy
162+
\`\`\`
163+
EOF
164+
165+
- name: Create GitHub Release
166+
uses: softprops/action-gh-release@v1
167+
with:
168+
tag_name: ${{ steps.tag.outputs.tag }}
169+
name: tiny-proxy ${{ steps.tag.outputs.tag }}
170+
body_path: release_notes.md
171+
files: dist/**/*
172+
draft: false
173+
prerelease: ${{ contains(steps.tag.outputs.tag, '-') }}
174+
env:
175+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)