Skip to content

Commit

Permalink
devops: Add CD workflow using release-plz
Browse files Browse the repository at this point in the history
  • Loading branch information
cvauclair committed Sep 4, 2024
1 parent 1543dbc commit e5a1461
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 2 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: "Build & Release"

permissions:
# To upload files to GitHub Releases
contents: write

on:
push:
branches:
- main
secrets:
CARGO_REGISTRY_TOKEN:
description: "Token to publish to crates.io"
required: true
GITHUB_TOKEN:
description: "Github Token to enable PR creation"
required: true

jobs:
validate-input:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Validate input
id: regex-match
run: |
text="${INPUT_VERSION}";
regex="^v([0-9]+)\.([0-9]+)\.([0-9]+)-?([[:alnum:]]*)\+?([0-9]*)$";
# Perform the regex match
if grep -qE "$regex" <<< "$text"; then
echo "match=true" >> "$GITHUB_OUTPUT";
else
echo "match=false" >> "$GITHUB_OUTPUT";
fi
- name: Fail if don't match regex
if: ${{ inputs.version && steps.regex-match.outputs.match == 'false' }}
run: |
echo "${{inputs.version}} doesn't match regex. Use a version similar to v3.1.4-alpha+159"
exit 1;
run-ci:
needs: validate-input
uses: ./.github/workflows/ci.yaml

release-plz:
name: Release-plz
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Run release-plz
uses: MarcoIeni/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
8 changes: 6 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Inspired by https://github.com/joshka/github-workflows/blob/main/.github/workflows/rust-check.yml
name: Lint & Test

on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
workflow_call:

env:
CARGO_TERM_COLOR: always

# ensure that the workflow is only triggered once per PR, subsequent pushes to the PR will cancel
# and restart the workflow. See https://docs.github.com/en/actions/using-jobs/using-concurrency
Expand Down

0 comments on commit e5a1461

Please sign in to comment.