diff --git a/.github/workflows/rust.yml b/.github/workflows/ci.yml similarity index 79% rename from .github/workflows/rust.yml rename to .github/workflows/ci.yml index e6049ca..c2f1050 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/ci.yml @@ -1,13 +1,16 @@ -name: Rust +name: CI on: push: + tags: + - "v*" branches: [ master ] pull_request: branches: [ master ] jobs: build: + name: Build runs-on: ubuntu-latest @@ -30,3 +33,9 @@ jobs: run: cargo build --no-default-features --features rustls - name: Run tests with rustls run: cargo test --no-default-features --features rustls + publish: + name: Publish + if: startsWith( github.ref, 'refs/tags/v' ) + uses: ./.github/workflows/release.yml + needs: build + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f2f1e40 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +name: Publish to crates.io and draft release + +on: + workflow_call: + secrets: + CRATES_TOKEN: + required: true + +jobs: + publish: + name: Publish to crates.io + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.71.1 + - run: | + cargo publish --token ${CRATES_TOKEN} + env: + CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }} + release: + name: Release on GitHub + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Create a Release + uses: elgohr/Github-Release-Action@v5 + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + title: ${{ github.ref }} + tag: ${{ github.ref }} \ No newline at end of file