Skip to content

Commit

Permalink
chore: automate versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
niek-mereu committed Feb 7, 2023
1 parent 6814ff9 commit 8f128e7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
name: Publish to Pypi
on:
push:
branches:
- 'master'
tags:
- '*'

jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Checkout
uses: actions/checkout@master
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
Expand All @@ -20,21 +21,25 @@ jobs:
pip install
build
--user
- name: Extract tag name
id: tag
run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3)
- name: Update version in setup.py
run: >-
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" setup.py
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,19 +244,18 @@ When incrementing the MINOR version, reset the PATCH version to 0.

When a version is released, a tag should be created in the format `vMAJOR.MINOR.PATCH`.

Follow the steps below to create a new release:
1. Update `package.json` with the new version number.
2. Add the tag to the current branch like this:
A new version is not automatically released upon merging into master. Follow the steps below to create a new release:

1. Add the tag to the current branch like this:

```
git tag -a v1.0.0 -m "Release version 1.0.0"
```
3. Push the tag to the remote repository:
2. Push the tag to the remote repository:

```
git push origin --tags
```
4. Create a new pull request with the new version number and merge it to the `master` branch.

### <a name="contributors">:pencil: Contributors</a>

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "osmanager",
"version": "1.0.2",
"description": "OpenSearch manager repository.",
"author": "STRV DS Department <[email protected]>",
"email": "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name=package_info["name"],
version=package_info["version"],
version="{{VERSION_PLACEHOLDER}}",
author=package_info["author"],
author_email=package_info["email"],
url=package_info["url"],
Expand Down

0 comments on commit 8f128e7

Please sign in to comment.