Skip to content

chore: release v1.0.5 #7

chore: release v1.0.5

chore: release v1.0.5 #7

Workflow file for this run

name: Publish
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
defaults:
run:
shell: bash
permissions:
contents: read
jobs:
test:
uses: ./.github/workflows/test.yml
secrets: inherit
publish:
needs: test
name: Publish package
runs-on: ubuntu-latest
env:
NAME: qs_rust
environment:
name: crates.io
url: https://crates.io/crates/${{ env.NAME }}
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Compare package version with ref/tag
id: compare
run: |
set -euo pipefail
pkgid="$(cargo pkgid)"
VERSION="${pkgid##*#}"
TAG="${GITHUB_REF_NAME#v}"
if [[ "${VERSION}" != "${TAG}" ]]; then
echo "Package version (${VERSION}) does not match tag (${TAG})"
exit 1
fi
echo "VERSION=${VERSION}" >> "${GITHUB_ENV}"
- name: Check CHANGELOG.md
id: check_changelog
run: |
set -euo pipefail
if ! grep -Eq "^##[[:space:]]+${VERSION}([[:space:]]|$)" CHANGELOG.md; then
echo "CHANGELOG.md does not contain a section for ${VERSION}"
exit 1
fi
- name: Publish dry run
run: cargo publish --dry-run --locked
- name: Publish package to crates.io
id: publish
if: startsWith(github.ref, 'refs/tags')
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --locked
- name: Create tag-specific CHANGELOG
id: create_changelog
run: |
set -euo pipefail
CHANGELOG_PATH="${RUNNER_TEMP}/CHANGELOG.md"
awk -v ver="${VERSION}" '
$0 ~ "^##[[:space:]]+" ver "([[:space:]]|$)" {print; insec=1; next}
insec && /^##[[:space:]]/ {exit}
insec {print}
' CHANGELOG.md | sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' > "${CHANGELOG_PATH}"
printf "\n**crates.io:** https://crates.io/crates/%s/%s\n" "${NAME}" "${VERSION}" >> "${CHANGELOG_PATH}"
printf "**docs.rs:** https://docs.rs/%s/%s\n" "${NAME}" "${VERSION}" >> "${CHANGELOG_PATH}"
echo "CHANGELOG_PATH=${CHANGELOG_PATH}" >> "${GITHUB_ENV}"
- name: Github Release
id: github_release
uses: softprops/action-gh-release@v3
with:
name: ${{ env.VERSION }}
tag_name: ${{ github.ref_name }}
body_path: ${{ env.CHANGELOG_PATH }}
files: |
target/package/${{ env.NAME }}-${{ env.VERSION }}.crate
- name: Cleanup
if: ${{ always() }}
run: |
rm -f "${CHANGELOG_PATH:-}"
rm -rf "target/package/${NAME}-${VERSION}"
rm -f "target/package/${NAME}-${VERSION}.crate"
docs:
uses: ./.github/workflows/docs.yml
needs: [test, publish]
permissions:
contents: write
secrets: inherit