-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
devops: Add CD workflow using release-plz
- Loading branch information
Showing
2 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters