From a5999351cf5f596ed27f21c0f4b358d8d7f121db Mon Sep 17 00:00:00 2001 From: Steven Hoelscher Date: Sun, 15 Jan 2023 18:35:21 -0800 Subject: [PATCH] chore: add release workflow (#360) Adds release workflow that (1) creates a GitHub release and (2) publishes built artifacts to PyPI **Release Workflow** 1. Checkout `master` locally and cut a new branch 1. Run `poetry version ` to version bump (e.g., `poetry version patch`) 1. Commit changes and push to remote branch 1. Ensure all quality check workflows pass 1. Explicitly tag PR with `release` label 1. Merge to mainline At this point, a release workflow should be triggered because: * The PR is closed, targeting `master`, and merged * `pyproject.toml` has been detected as modified * The PR had a `release` label The workflow will then proceed to build the artifacts, create a GitHub release with release notes and uploaded artifacts, and publish to PyPI. Example Workflow run: https://github.com/shoelsch/langchain/actions/runs/3711037455/jobs/6291076898 Example Releases: https://github.com/shoelsch/langchain/releases -- Note, this workflow is looking for the `PYPI_API_TOKEN` secret, so that will need to be uploaded to the repository secrets. I tested uploading as far as hitting a permissions issue due to project ownership in Test PyPI. --- .github/workflows/release.yml | 49 +++++++++++++++++++++++++++++++++++ README.md | 3 +-- 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..1c5853c5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,49 @@ +name: release + +on: + pull_request: + types: + - closed + branches: + - master + paths: + - 'pyproject.toml' + +env: + POETRY_VERSION: "1.3.1" + +jobs: + if_release: + if: | + ${{ github.event.pull_request.merged == true }} + && ${{ contains(github.event.pull_request.labels.*.name, 'release') }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install poetry + run: pipx install poetry==$POETRY_VERSION + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + cache: "poetry" + - name: Build project for distribution + run: poetry build + - name: Check Version + id: check-version + run: | + echo version=$(poetry version --short) >> $GITHUB_OUTPUT + - name: Create Release + uses: ncipollo/release-action@v1 + with: + artifacts: "dist/*" + token: ${{ secrets.GITHUB_TOKEN }} + draft: false + generateReleaseNotes: true + tag: v${{ steps.check-version.outputs.version }} + commit: master + - name: Publish to PyPI + env: + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }} + run: | + poetry publish diff --git a/README.md b/README.md index f3add312..0d76099a 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,6 @@ For more information on these concepts, please see our [full documentation](http ## 💁 Contributing -As an open source project in a rapidly developing field, we are extremely open -to contributions, whether it be in the form of a new feature, improved infra, or better documentation. +As an open source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infra, or better documentation. For detailed information on how to contribute, see [here](CONTRIBUTING.md).