Skip to content

Commit 43bcbca

Browse files
authored
chore: release 0.1.0 (#4)
* chore: release 0.1.0 * chore: set pr-run-mode to plan * ci: try to fix windows build * chore: set pr-run-mode to plan
1 parent c826504 commit 43bcbca

File tree

7 files changed

+463
-1
lines changed

7 files changed

+463
-1
lines changed

.github/workflows/ci.yaml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request: {}
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
- name: Install Rust toolchain
15+
uses: dtolnay/rust-toolchain@nightly
16+
- uses: Swatinem/rust-cache@v2
17+
- name: Run tests
18+
run: cargo build --all-features --all-targets --workspace
19+
20+
test:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
- name: Install Rust toolchain
26+
uses: dtolnay/rust-toolchain@nightly
27+
- uses: Swatinem/rust-cache@v2
28+
- name: Install nextest
29+
uses: taiki-e/install-action@nextest
30+
- name: Run tests
31+
run: cargo nextest run --all-features --workspace
32+
33+
rustfmt:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v4
38+
- name: Install Rust toolchain
39+
uses: dtolnay/rust-toolchain@nightly
40+
with:
41+
components: rustfmt
42+
- uses: Swatinem/rust-cache@v2
43+
- name: Check formatting
44+
run: cargo fmt --all --check
45+
46+
clippy:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
- name: Install Rust toolchain
52+
uses: dtolnay/rust-toolchain@nightly
53+
with:
54+
components: clippy
55+
- uses: Swatinem/rust-cache@v2
56+
- name: Clippy check
57+
run: cargo clippy --all-targets --all-features --workspace -- -D warnings

.github/workflows/release.yml

+260
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
# Copyright 2022-2023, axodotdev
2+
# SPDX-License-Identifier: MIT or Apache-2.0
3+
#
4+
# CI that:
5+
#
6+
# * checks for a Git Tag that looks like a release
7+
# * builds artifacts with cargo-dist (archives, installers, hashes)
8+
# * uploads those artifacts to temporary workflow zip
9+
# * on success, uploads the artifacts to a Github Release
10+
#
11+
# Note that the Github Release will be created with a generated
12+
# title/body based on your changelogs.
13+
14+
name: Release
15+
16+
permissions:
17+
contents: write
18+
19+
# This task will run whenever you push a git tag that looks like a version
20+
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
21+
# Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where
22+
# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION
23+
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
24+
#
25+
# If PACKAGE_NAME is specified, then the announcement will be for that
26+
# package (erroring out if it doesn't have the given version or isn't cargo-dist-able).
27+
#
28+
# If PACKAGE_NAME isn't specified, then the announcement will be for all
29+
# (cargo-dist-able) packages in the workspace with that version (this mode is
30+
# intended for workspaces with only one dist-able package, or with all dist-able
31+
# packages versioned/released in lockstep).
32+
#
33+
# If you push multiple tags at once, separate instances of this workflow will
34+
# spin up, creating an independent announcement for each one. However Github
35+
# will hard limit this to 3 tags per commit, as it will assume more tags is a
36+
# mistake.
37+
#
38+
# If there's a prerelease-style suffix to the version, then the release(s)
39+
# will be marked as a prerelease.
40+
on:
41+
push:
42+
tags:
43+
- '**[0-9]+.[0-9]+.[0-9]+*'
44+
pull_request:
45+
46+
jobs:
47+
# Run 'cargo dist plan' (or host) to determine what tasks we need to do
48+
plan:
49+
runs-on: ubuntu-latest
50+
outputs:
51+
val: ${{ steps.plan.outputs.manifest }}
52+
tag: ${{ !github.event.pull_request && github.ref_name || '' }}
53+
tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }}
54+
publishing: ${{ !github.event.pull_request }}
55+
env:
56+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
steps:
58+
- uses: actions/checkout@v4
59+
with:
60+
submodules: recursive
61+
- name: Install cargo-dist
62+
# we specify bash to get pipefail; it guards against the `curl` command
63+
# failing. otherwise `sh` won't catch that `curl` returned non-0
64+
shell: bash
65+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.6.2/cargo-dist-installer.sh | sh"
66+
# sure would be cool if github gave us proper conditionals...
67+
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
68+
# functionality based on whether this is a pull_request, and whether it's from a fork.
69+
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
70+
# but also really annoying to build CI around when it needs secrets to work right.)
71+
- id: plan
72+
run: |
73+
cargo dist ${{ !github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name) || (github.event.pull_request.head.repo.fork && 'plan' || 'host --steps=check') }} --output-format=json > dist-manifest.json
74+
echo "cargo dist ran successfully"
75+
cat dist-manifest.json
76+
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
77+
- name: "Upload dist-manifest.json"
78+
uses: actions/upload-artifact@v3
79+
with:
80+
name: artifacts
81+
path: dist-manifest.json
82+
83+
# Build and packages all the platform-specific things
84+
build-local-artifacts:
85+
name: build-local-artifacts (${{ join(matrix.targets, ', ') }})
86+
# Let the initial task tell us to not run (currently very blunt)
87+
needs:
88+
- plan
89+
if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }}
90+
strategy:
91+
fail-fast: false
92+
# Target platforms/runners are computed by cargo-dist in create-release.
93+
# Each member of the matrix has the following arguments:
94+
#
95+
# - runner: the github runner
96+
# - dist-args: cli flags to pass to cargo dist
97+
# - install-dist: expression to run to install cargo-dist on the runner
98+
#
99+
# Typically there will be:
100+
# - 1 "global" task that builds universal installers
101+
# - N "local" tasks that build each platform's binaries and platform-specific installers
102+
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
103+
runs-on: ${{ matrix.runner }}
104+
env:
105+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106+
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
107+
steps:
108+
- uses: actions/checkout@v4
109+
with:
110+
submodules: recursive
111+
- uses: swatinem/rust-cache@v2
112+
- name: Install cargo-dist
113+
run: ${{ matrix.install_dist }}
114+
# Get the dist-manifest
115+
- name: Fetch local artifacts
116+
uses: actions/download-artifact@v3
117+
with:
118+
name: artifacts
119+
path: target/distrib/
120+
- name: Install dependencies
121+
run: |
122+
${{ matrix.packages_install }}
123+
- name: Build artifacts
124+
run: |
125+
# Actually do builds and make zips and whatnot
126+
cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
127+
echo "cargo dist ran successfully"
128+
- id: cargo-dist
129+
name: Post-build
130+
# We force bash here just because github makes it really hard to get values up
131+
# to "real" actions without writing to env-vars, and writing to env-vars has
132+
# inconsistent syntax between shell and powershell.
133+
shell: bash
134+
run: |
135+
# Parse out what we just built and upload it to scratch storage
136+
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
137+
jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT"
138+
echo "EOF" >> "$GITHUB_OUTPUT"
139+
140+
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
141+
- name: "Upload artifacts"
142+
uses: actions/upload-artifact@v3
143+
with:
144+
name: artifacts
145+
path: |
146+
${{ steps.cargo-dist.outputs.paths }}
147+
${{ env.BUILD_MANIFEST_NAME }}
148+
149+
# Build and package all the platform-agnostic(ish) things
150+
build-global-artifacts:
151+
needs:
152+
- plan
153+
- build-local-artifacts
154+
runs-on: "ubuntu-20.04"
155+
env:
156+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157+
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
158+
steps:
159+
- uses: actions/checkout@v4
160+
with:
161+
submodules: recursive
162+
- name: Install cargo-dist
163+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.6.2/cargo-dist-installer.sh | sh"
164+
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
165+
- name: Fetch local artifacts
166+
uses: actions/download-artifact@v3
167+
with:
168+
name: artifacts
169+
path: target/distrib/
170+
- id: cargo-dist
171+
shell: bash
172+
run: |
173+
cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
174+
echo "cargo dist ran successfully"
175+
176+
# Parse out what we just built and upload it to scratch storage
177+
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
178+
jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT"
179+
echo "EOF" >> "$GITHUB_OUTPUT"
180+
181+
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
182+
- name: "Upload artifacts"
183+
uses: actions/upload-artifact@v3
184+
with:
185+
name: artifacts
186+
path: |
187+
${{ steps.cargo-dist.outputs.paths }}
188+
${{ env.BUILD_MANIFEST_NAME }}
189+
# Determines if we should publish/announce
190+
host:
191+
needs:
192+
- plan
193+
- build-local-artifacts
194+
- build-global-artifacts
195+
# Only run if we're "publishing", and only if local and global didn't fail (skipped is fine)
196+
if: ${{ always() && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }}
197+
env:
198+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
199+
runs-on: "ubuntu-20.04"
200+
outputs:
201+
val: ${{ steps.host.outputs.manifest }}
202+
steps:
203+
- uses: actions/checkout@v4
204+
with:
205+
submodules: recursive
206+
- name: Install cargo-dist
207+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.6.2/cargo-dist-installer.sh | sh"
208+
# Fetch artifacts from scratch-storage
209+
- name: Fetch artifacts
210+
uses: actions/download-artifact@v3
211+
with:
212+
name: artifacts
213+
path: target/distrib/
214+
# This is a harmless no-op for Github Releases, hosting for that happens in "announce"
215+
- id: host
216+
shell: bash
217+
run: |
218+
cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
219+
echo "artifacts uploaded and released successfully"
220+
cat dist-manifest.json
221+
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
222+
- name: "Upload dist-manifest.json"
223+
uses: actions/upload-artifact@v3
224+
with:
225+
name: artifacts
226+
path: dist-manifest.json
227+
228+
# Create a Github Release while uploading all files to it
229+
announce:
230+
needs:
231+
- plan
232+
- host
233+
# use "always() && ..." to allow us to wait for all publish jobs while
234+
# still allowing individual publish jobs to skip themselves (for prereleases).
235+
# "host" however must run to completion, no skipping allowed!
236+
if: ${{ always() && needs.host.result == 'success' }}
237+
runs-on: "ubuntu-20.04"
238+
env:
239+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
240+
steps:
241+
- uses: actions/checkout@v4
242+
with:
243+
submodules: recursive
244+
- name: "Download Github Artifacts"
245+
uses: actions/download-artifact@v3
246+
with:
247+
name: artifacts
248+
path: artifacts
249+
- name: Cleanup
250+
run: |
251+
# Remove the granular manifests
252+
rm -f artifacts/*-dist-manifest.json
253+
- name: Create Github Release
254+
uses: ncipollo/release-action@v1
255+
with:
256+
tag: ${{ needs.plan.outputs.tag }}
257+
name: ${{ fromJson(needs.host.outputs.val).announcement_title }}
258+
body: ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
259+
prerelease: ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
260+
artifacts: "artifacts/*"

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [0.1.0] - 2023-12-28
6+
7+
### Features
8+
9+
- Proxy http to tor
10+
- Add cli options
11+
12+
### Miscellaneous Tasks
13+
14+
- Upgrade deps (#2)
15+

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+25-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ name = "cipolla"
33
authors = ["Mark Hähnel <[email protected]>"]
44
version = "0.1.0"
55
edition = "2021"
6+
repository = "https://github.com/markhaehnel/cipolla-rs.git"
67

78
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
89

910
[dependencies]
1011
anyhow = { version = "1.0.75" }
11-
arti-client = { version = "0.12.0", features = ["geoip"] }
12+
arti-client = { version = "0.12.0", features = ["geoip", "static-sqlite"] }
1213
axum = { version = "0.6.20" }
1314
clap = { version = "4.4.11", features = ["cargo", "derive"] }
1415
hyper = { version = "0.14.27" }
@@ -19,3 +20,26 @@ tower = { version = "0.4.13" }
1920
tower-http = { version = "0.4.4", features = ["trace"] }
2021
tracing = { version = "0.1.40" }
2122
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
23+
24+
# The profile that 'cargo dist' will build with
25+
[profile.dist]
26+
inherits = "release"
27+
lto = "thin"
28+
29+
# Config for 'cargo dist'
30+
[workspace.metadata.dist]
31+
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
32+
cargo-dist-version = "0.6.2"
33+
# The installers to generate for each app
34+
installers = []
35+
# Target platforms to build apps for (Rust target-triple syntax)
36+
targets = [
37+
"x86_64-unknown-linux-gnu",
38+
"aarch64-apple-darwin",
39+
"x86_64-apple-darwin",
40+
"x86_64-pc-windows-msvc",
41+
]
42+
# CI backends to support
43+
ci = ["github"]
44+
# Publish jobs to run in CI
45+
pr-run-mode = "plan"

0 commit comments

Comments
 (0)