Skip to content

Release

Release #3

Workflow file for this run

# Project: hs-rustlib
# File: .github/workflows/release.yml
# Purpose: Build, test, and publish to Artifactory on release
# License: LicenseRef-HyperSec-EULA
# Copyright: (c) 2025 HyperSec
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
skip_publish:
description: "Skip publishing to Artifactory"
default: false
required: false
type: boolean
dry_run:
description: "Dry run (verify publish only)"
default: false
required: false
type: boolean
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
CARGO_BUILD_JOBS: 2
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Configure Artifactory registry
run: |
mkdir -p ~/.cargo
echo '[registries.hypersec]' > ~/.cargo/config.toml
echo 'index = "sparse+https://hypersec.jfrog.io/artifactory/api/cargo/hypersec-cargo-virtual/index/"' >> ~/.cargo/config.toml
echo '[registries.hypersec]' > ~/.cargo/credentials.toml
echo "token = \"Bearer ${{ secrets.CARGO_REGISTRY_TOKEN }}\"" >> ~/.cargo/credentials.toml
echo "=== config.toml ===" && cat ~/.cargo/config.toml
echo "=== credentials.toml (header only) ===" && head -1 ~/.cargo/credentials.toml
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
- name: Determine version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION=$(grep -E '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
echo "Using version from Cargo.toml: $VERSION"
else
VERSION=${GITHUB_REF#refs/tags/v}
echo "Using version from tag: $VERSION"
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Verify version in Cargo.toml
run: |
CARGO_VERSION=$(grep -E '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
echo "Cargo.toml version: $CARGO_VERSION"
echo "Expected version: $VERSION"
if [ "$CARGO_VERSION" != "$VERSION" ]; then
echo "::error::Version mismatch: Cargo.toml=$CARGO_VERSION, expected=$VERSION"
exit 1
fi
- name: Build
run: cargo build --all-features --release
- name: Run tests
run: cargo test --all-features
- name: Run clippy
run: cargo clippy --all-features -- -D warnings
- name: Verify publish (dry-run)
if: ${{ inputs.dry_run == true }}
run: cargo publish --registry hypersec --dry-run --no-verify
- name: Publish to Artifactory
if: ${{ inputs.skip_publish == false && inputs.dry_run == false }}
run: cargo publish --registry hypersec --no-verify
- name: Create GitHub Release
if: ${{ github.event_name == 'push' }}
uses: softprops/action-gh-release@v1
with:
draft: false
prerelease: ${{ contains(env.VERSION, '-rc') || contains(env.VERSION, '-beta') || contains(env.VERSION, '-alpha') }}
tag_name: v${{ env.VERSION }}
name: Release v${{ env.VERSION }}
generate_release_notes: true