Skip to content

Publish

Publish #243

Workflow file for this run

name: Publish
on:
workflow_run:
workflows:
- CI
branches:
- main
types:
- completed
jobs:
bump:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
name: publish release and crate
steps:
- name: Check out
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
with:
prefix-key: ubuntu-latest
shared-key: "pdylanross/fatigue"
- uses: actions-rs/[email protected]
with:
crate: cargo-edit
version: 0.11.9
use-tool-cache: true
- name: Create bump and changelog
id: cz
uses: commitizen-tools/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
changelog_increment_filename: body.md
commit: false
push: false
- id: should_publish
shell: bash
run: |
set -ex
cargo build --bin fatigue
OLD_VERSION="$(./target/debug/fatigue --version)"
if [[ "$OLD_VERSION" == "fatigue ${{ env.REVISION }}" ]]; then
OUTPUT="false"
else
OUTPUT="true"
fi
echo "update=$OUTPUT" >> $GITHUB_OUTPUT
- run: cargo set-version ${{ env.REVISION }} --workspace
if: steps.should_publish.outputs.update == 'true'
- run: cargo upgrade -p libfatigue@${{ env.REVISION }}
if: steps.should_publish.outputs.update == 'true'
# for some reason, the generated changelog from cz
# doesn't have the correct file permissions for git add
- run: sudo chmod -R ugo+rwX .
name: fixup permissions from cz
if: steps.should_publish.outputs.update == 'true'
- uses: EndBug/add-and-commit@v9
if: steps.should_publish.outputs.update == 'true'
id: add-and-commit
with:
message: "[skip ci] release: ${{ env.REVISION }}"
push: true
tag: ${{ env.REVISION }}
- name: Release
if: steps.should_publish.outputs.update == 'true'
uses: softprops/action-gh-release@v2
with:
body_path: "body.md"
tag_name: ${{ env.REVISION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: katyo/publish-crates@v2
if: steps.should_publish.outputs.update == 'true'
name: Release lib
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
publish-delay: 1000