diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml new file mode 100644 index 00000000..5f22255a --- /dev/null +++ b/.github/workflows/cd.yaml @@ -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/release-plz-action@v0.5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 488d8e28..c3ced72f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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