diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 241b5f23..6401d8e5 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -63,3 +63,16 @@ jobs: uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} + + publish-crate: + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + needs: [test] + steps: + - name: Set up Rust + uses: hecrj/setup-rust-action@v1 + - uses: actions/checkout@v2 + - name: Publish + shell: bash + run: | + cargo publish --token ${{ secrets.CRATES_TOKEN }} diff --git a/Cargo.toml b/Cargo.toml index ad02e5ee..beed4db1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,3 +34,6 @@ serde_json = { version = "1.0", optional = true } [dev-dependencies] simple_logger = "1.6" matches = "0.1" + +[package.metadata.release] +disable-publish = true diff --git a/docs/releasing.md b/docs/releasing.md new file mode 100644 index 00000000..66b41901 --- /dev/null +++ b/docs/releasing.md @@ -0,0 +1,37 @@ +# Releasing + +Releasing, i.e. crate publishing, has been automated via GitHub Actions. + +We use the [`cargo release`](https://github.com/sunng87/cargo-release) +subcommand to ensure correct versioning. Install via: + +``` +$ cargo install cargo-release +``` + +**Before releasing** ensure `CHANGELOG.md` is updated appropriately. + +## Process + +Using `cargo-release` we can author a new minor release like so: + +``` +$ cargo release minor --skip-publish +``` + +**Ensure publishing is skipped** since pushing the resulting tag upstream will +handle crate publishing automatically. + +This will create a new tag, `0.6.0` with the message, +`(cargo-release) sqlparser version 0.6.0`. + +Once the tag is created, pushing the tag upstream will trigger a publishing +process to crates.io. Now to push our example tag: + +``` +git push origin 0.6.0 +``` + +(Note that this process is fully automated; credentials +for authoring in this way are securely stored in the repo secrets as +`CRATE_TOKEN`.)