mirror of
https://github.com/seemueller-io/hyper-custom-cert.git
synced 2025-09-08 22:46:45 +00:00
init: publish public repository
This commit is contained in:
149
.github/workflows/release.yml
vendored
Normal file
149
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test before release
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: crates/hyper-custom-cert
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: default (native-tls)
|
||||
features: ""
|
||||
no-default-features: false
|
||||
- name: no-default-features (no TLS)
|
||||
features: ""
|
||||
no-default-features: true
|
||||
- name: rustls
|
||||
features: "rustls"
|
||||
no-default-features: true
|
||||
- name: insecure-dangerous (native-tls)
|
||||
features: "insecure-dangerous"
|
||||
no-default-features: false
|
||||
- name: rustls + insecure-dangerous
|
||||
features: "rustls,insecure-dangerous"
|
||||
no-default-features: true
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
components: clippy, rustfmt
|
||||
|
||||
- name: Cargo fmt (check)
|
||||
run: cargo fmt --all -- --check
|
||||
|
||||
- name: Clippy
|
||||
shell: bash
|
||||
run: |
|
||||
FLAGS=""
|
||||
if [ "${{ matrix.no-default-features }}" = "true" ]; then FLAGS="$FLAGS --no-default-features"; fi
|
||||
if [ -n "${{ matrix.features }}" ]; then FLAGS="$FLAGS --features ${{ matrix.features }}"; fi
|
||||
echo "Running: cargo clippy --all-targets $FLAGS -- -D warnings"
|
||||
cargo clippy --all-targets $FLAGS -- -D warnings
|
||||
|
||||
- name: Tests
|
||||
shell: bash
|
||||
run: |
|
||||
FLAGS=""
|
||||
if [ "${{ matrix.no-default-features }}" = "true" ]; then FLAGS="$FLAGS --no-default-features"; fi
|
||||
if [ -n "${{ matrix.features }}" ]; then FLAGS="$FLAGS --features ${{ matrix.features }}"; fi
|
||||
echo "Running: cargo test $FLAGS -- --nocapture"
|
||||
cargo test $FLAGS -- --nocapture
|
||||
|
||||
publish:
|
||||
name: Publish to crates.io
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
defaults:
|
||||
run:
|
||||
working-directory: crates/hyper-custom-cert
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Verify tag matches version
|
||||
run: |
|
||||
TAG_VERSION=${GITHUB_REF#refs/tags/v}
|
||||
CARGO_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
|
||||
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
|
||||
echo "Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Publish to crates.io
|
||||
env:
|
||||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
||||
run: cargo publish
|
||||
|
||||
release:
|
||||
name: Create GitHub Release
|
||||
runs-on: ubuntu-latest
|
||||
needs: [test, publish]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Extract tag name
|
||||
id: tag
|
||||
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Generate changelog
|
||||
id: changelog
|
||||
run: |
|
||||
# Get the previous tag
|
||||
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
|
||||
|
||||
# Generate changelog
|
||||
if [ -n "$PREV_TAG" ]; then
|
||||
echo "## What's Changed" > changelog.md
|
||||
echo "" >> changelog.md
|
||||
git log --pretty=format:"* %s (%h)" ${PREV_TAG}..HEAD >> changelog.md
|
||||
echo "" >> changelog.md
|
||||
echo "" >> changelog.md
|
||||
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...${{ steps.tag.outputs.tag }}" >> changelog.md
|
||||
else
|
||||
echo "## What's Changed" > changelog.md
|
||||
echo "" >> changelog.md
|
||||
echo "Initial release of hyper-custom-cert" >> changelog.md
|
||||
echo "" >> changelog.md
|
||||
echo "A small, ergonomic HTTP client wrapper around hyper with optional support for custom Root CAs and a dev-only insecure mode for self-signed certificates." >> changelog.md
|
||||
fi
|
||||
|
||||
# Set the changelog as output (handle multiline)
|
||||
echo "changelog<<EOF" >> $GITHUB_OUTPUT
|
||||
cat changelog.md >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create Release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
if [[ "${{ steps.tag.outputs.tag }}" == *"-"* ]]; then
|
||||
PRERELEASE_FLAG="--prerelease"
|
||||
else
|
||||
PRERELEASE_FLAG=""
|
||||
fi
|
||||
|
||||
gh release create "${{ steps.tag.outputs.tag }}" \
|
||||
--title "Release ${{ steps.tag.outputs.tag }}" \
|
||||
--notes-file changelog.md \
|
||||
$PRERELEASE_FLAG
|
Reference in New Issue
Block a user