Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- run: cargo fmt --check
- run: cargo clippy --locked --all-targets -- -D warnings
- run: cargo test --locked
- run: cargo build --locked --release
36 changes: 36 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Pages

# Publishes docs/ to GitHub Pages. Requires Settings → Pages → Source:
# "GitHub Actions".
on:
push:
branches: [main]
paths: ["docs/**", ".github/workflows/pages.yml"]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: pages
cancel-in-progress: false

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
- uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5
- uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3
with:
path: docs
- id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4
99 changes: 99 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Release

# Push a tag `vX.Y.Z` matching the version in Cargo.toml to publish a release
# with static Linux binaries, SHA256SUMS and build provenance attestations.
on:
push:
tags: ["v*.*.*"]

permissions:
contents: read

jobs:
build:
name: build (${{ matrix.target }})
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
target: [x86_64-unknown-linux-musl, aarch64-unknown-linux-musl]
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false

- name: Check tag matches Cargo.toml version
run: |
version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
if [ "v$version" != "$GITHUB_REF_NAME" ]; then
echo "Tag $GITHUB_REF_NAME does not match Cargo.toml version $version." >&2
exit 1
fi

- uses: dtolnay/rust-toolchain@89b12181fb390509a0842a86cc55eeb8eb928c1d # stable
with:
targets: ${{ matrix.target }}

# zig serves as C compiler/linker for ring when cross-compiling to musl.
# setup-python avoids the runner's externally managed system Python.
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.12"
- name: Install cargo-zigbuild
run: pip install cargo-zigbuild==0.23.4 ziglang==0.16.0

- name: Test
run: cargo test --locked

- name: Build
run: cargo zigbuild --locked --release --target ${{ matrix.target }}

- name: Package
run: |
name="dns-proxy-${GITHUB_REF_NAME}-${{ matrix.target }}"
mkdir -p "pkg/$name/dist"
cp "target/${{ matrix.target }}/release/dns-proxy" "pkg/$name/"
cp LICENSE README.md config.example.toml "pkg/$name/"
cp dist/dns-proxy.service "pkg/$name/dist/"
tar -C pkg --owner=0 --group=0 --numeric-owner -czf "$name.tar.gz" "$name"

- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: ${{ matrix.target }}
path: dns-proxy-*.tar.gz
if-no-files-found: error

release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write # create the release
id-token: write # sign the provenance attestation
attestations: write # store the attestation
steps:
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
path: out
merge-multiple: true

- name: Checksums
working-directory: out
run: sha256sum dns-proxy-*.tar.gz > SHA256SUMS && cat SHA256SUMS

- uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2
with:
subject-path: out/dns-proxy-*.tar.gz

- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
run: |
flags=""
case "$GITHUB_REF_NAME" in *-*) flags="--prerelease" ;; esac
gh release create "$GITHUB_REF_NAME" \
--repo "$GITHUB_REPOSITORY" \
--verify-tag \
--generate-notes \
--title "$GITHUB_REF_NAME" \
$flags \
out/dns-proxy-*.tar.gz out/SHA256SUMS
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
Loading
Loading