Release new version (#163) #140
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| branches: | |
| - 'master' | |
| jobs: | |
| run-tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Get tags | |
| run: git fetch --tags origin | |
| - name: Setup Python 3.9 | |
| uses: actions/setup-python@v2 | |
| with: | |
| python-version: 3.9 | |
| - name: Setup Poetry | |
| uses: abatilo/actions-poetry@v2.1.2 | |
| with: | |
| poetry-version: 1.4.2 | |
| - name: Install Dependencies | |
| run: | | |
| poetry install | |
| npm install | |
| - name: Run Lints | |
| run: | | |
| poetry run black -v --check . | |
| poetry run flake8 -v --ignore=E501,W503,E722 | |
| - name: Run Tests | |
| run: | | |
| poetry run pytest -v | |
| - name: Create Release Pull Request | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| title: 'New Release' | |
| commit: 'Release new version' | |
| version: npm run version | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create new release | |
| if: steps.changesets.outputs.hasChangesets == 'false' | |
| run: | | |
| npx changeset tag && git push origin --tags | |
| COMMIT_TAG=$(git tag --points-at HEAD) | |
| if [ -n "$COMMIT_TAG" ]; then | |
| echo "A tag is attached to HEAD. Creating a new release..." | |
| echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token | |
| CHANGELOG=$(awk ' | |
| BEGIN { recording=0; } | |
| /^## / { | |
| if(recording) { exit; } | |
| recording=1; | |
| next; | |
| } | |
| recording { | |
| print; | |
| } | |
| ' CHANGELOG.md) | |
| gh release create $COMMIT_TAG -t "$COMMIT_TAG" -n "$CHANGELOG" | |
| poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN_PROD }} | |
| poetry publish --build | |
| else | |
| echo "No tag attached to HEAD. No new release needed." | |
| fi |