Skip to content

Commit

Permalink
Merge pull request #1 from github/oss
Browse files Browse the repository at this point in the history
Add OSS-compliance files/documentation.
  • Loading branch information
patrickt authored Jan 16, 2024
2 parents cf92c5f + 08b67ba commit 58b6deb
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @github/blackbird
65 changes: 65 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
## Contributing

[fork]: https://github.com/github/twirp-rs/fork
[pr]: https://github.com/github/twirp-rs/compare
[code-of-conduct]: CODE_OF_CONDUCT.md

Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.

Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE.md).

Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.

## Prerequisites for running and testing code

We recommend that you install Rust with the `rustup` tool. `twirp-rs` targets stable Rust versions.

## Submitting a pull request

1. [Fork][fork] and clone the repository.
1. Install `protoc` with your package manager of choice.
1. Build the software: `cargo build`.
1. Create a new branch: `git checkout -b my-branch-name`.
1. Make your change, add tests, and make sure the tests and linter still pass.
1. Push to your fork and [submit a pull request][pr].
1. Pat yourself on the back and wait for your pull request to be reviewed and merged.

Here are a few things you can do that will increase the likelihood of your pull request being accepted:

- Write tests.
- Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).

## Setting up a local build

Make sure you have [rust toolchain installed](https://www.rust-lang.org/tools/install) on your system and then:

```sh
cargo build && cargo test
```

Run clippy and fix any lints:

```sh
cargo fmt --all -- --check
cargo clippy -- --deny warnings -D clippy::unwrap_used
cargo clippy --tests -- --deny warnings -A clippy::unwrap_used
```

## Releasing (write access required)

If you are one of the maintainers of this package then follow this process:

1. Create a PR for this release with following changes:
- Updated `CHANGELOG.md` with desired change comments and ensure that it has the version to be released with date at the top.
- Go through all recent PRs and make sure they are properly accounted for.
- Make sure all changelog entries have links back to their PR(s) if appropriate.
- Update package version in Cargo.toml.
1. Get an approval and merge your PR.
1. Run ./script/publish from the `main` branch supplying your token and version information.

## Resources

- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
- [GitHub Help](https://help.github.com)
13 changes: 13 additions & 0 deletions SUPPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Support

## How to file issues and get help

This project uses GitHub issues to track bugs and feature requests. Please search the existing issues before filing new issues to avoid duplicates. For new issues, file your bug or feature request as a new issue.

For help or questions about using this project, please feel free to open an issue or start a discussion.

`twirp-rs` is under active development and maintained by GitHub staff. We will do our best to respond to support, feature requests, and community questions in a timely manner.

## GitHub Support Policy

Support for this project is limited to the resources listed above.
88 changes: 88 additions & 0 deletions script/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#! /usr/bin/env bash
#/ Publishes twirp-rs to crates.io
#/ Usage: script/publish --version <version> --token <token> [--upload]
#/
#/ version: Version to publish to crates.io.
#/ token: crates.io token to use for publishing.
#/ upload: Actually publishes the the crate to crates.io. By default this script
#/ runs cargo publish in dry-run mode

set -euo pipefail
IFS=$'\n\t'

function usage {
grep "^#/" "${BASH_SOURCE[0]}" | cut -c 4-
}


PKG_VERSION=$(cargo metadata --format-version 1 | jq -r '.workspace_members[0]' | awk '{print $2}')
MODE="--dry-run"
TOKEN=
VERSION=

if [[ -z "$(command -v jq)" ]]; then
echo "jq is required to run this script"
exit
fi


if [[ "$#" == 0 ]]
then
usage
exit
fi
# Ensure that the tests are still passing before publishing
cargo test --verbose

while [ $# -gt 0 ]; do
case "$1" in
--help|-h)
usage; shift ;;
--upload)
MODE=; shift ;;
--token)
TOKEN=$2; shift 2;;
--version)
VERSION=$2; shift 2 ;;
--)
shift; break ;;
*)
usage
exit
;;
esac
done

if [[ -z "${VERSION}" ]]; then
echo "Version is required"
exit
fi

if [[ -z "${TOKEN}" ]]; then
echo "Token is required"
exit
fi

if [[ $(git rev-parse --abbrev-ref HEAD) != "main" ]]
then
echo "You can only publish from main branch"
exit
fi

if [[ "${PKG_VERSION}" != "${VERSION}" ]]; then
echo "Version mismatched, cargo file: ${PKG_VERSION}, You supplied: ${VERSION}"
exit
fi

cargo package

if [[ "${MODE}" == "--dry-run" ]]; then
CMD="cargo publish --dry-run --token ${TOKEN}"
eval $CMD
else
git tag $VERSION
CMD="cargo publish --token ${TOKEN}"
echo "$CMD"
eval $CMD
git push origin $VERSION
fi

0 comments on commit 58b6deb

Please sign in to comment.