Skip to content

Commit

Permalink
Add "ci" and "publish" workflows
Browse files Browse the repository at this point in the history
The `ci` workflow will trigger the others appropriately, depending
whether it is a release (semver tag), or a pull request or a push to
master
  • Loading branch information
ureeves committed Nov 16, 2023
1 parent a5bcbc6 commit b72966d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 7 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: Check `healm`
name: Check
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_call:

jobs:
test:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on:
pull_request:
branches:
- master
push:
branches:
- master
tags:
- v*.*.*

jobs:
check:
uses: ./.github/workflows/check.yml

publish:
uses: ./.github/workflows/publish.yml
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
needs: check
with:
version: ${{ github.ref }}
secrets:
crates-io-token: ${{ secrets.CRATES_IO_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish
on:
workflow_call:
inputs:
version:
description: 'Semver of the version to publish'
type: string
required: true
secrets:
crates-io-token:
description: 'Token for publishing to crates.io'
required: true

jobs:
publish:
runs-on: ubuntu-latest
container:
image: rust:latest
steps:
- uses: actions/checkout@v3
- name: check manifest version
run: |
version=$(grep -oP '(?<=^version = ").*(?="$)' Cargo.toml)
if [ "$version" != "${{ inputs.version }}" ]; then
echo "Version mismatch: Cargo.toml version is $version, but workflow input version is ${{ inputs.version }}"
exit 1
fi
- run: cargo publish --token ${{ secrets.crates-io-token }} --dry-run

0 comments on commit b72966d

Please sign in to comment.