Skip to content

Commit

Permalink
ci(semantic-release): Add semantic release.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronmussig committed Dec 12, 2023
1 parent 024bfd8 commit 7b2417c
Show file tree
Hide file tree
Showing 5 changed files with 6,812 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Version, build, publish

on:
push:
branches:
- main

jobs:

semantic_release_next_version:
name: Next version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: npm
node-version: lts
- run: npm install
- run: npx semantic-release --dry-run
id: semantic_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v3
with:
name: semantic-release
path: |
betula/__init__.py
CHANGELOG.md
retention-days: 1
outputs:
version: ${{ steps.semantic_release.outputs.version }}

build_python_dist:
name: Python build *.tar.gz
runs-on: ubuntu-latest
needs: semantic_release_next_version
if: needs.semantic_release_next_version.outputs.version != ''
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: semantic-release
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v3
with:
name: pypi
path: dist/*.tar.gz
retention-days: 1

test_python_dist:
name: Python test *.tar.gz
runs-on: ubuntu-latest
needs: build_python_dist
steps:
- uses: actions/download-artifact@v3
with:
name: pypi
path: dist
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: python -m pip install dist/*.tar.gz

semantic_release_publish:
name: Publish to GitHub
needs: test_python_dist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: npm
node-version: lts
- run: npm install
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

upload_pypi:
name: Publish to PyPI
needs: semantic_release_publish
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: pypi
path: dist

- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,7 @@ dmypy.json
.pyre/

.idea/

node_modules/

.DS_Store
35 changes: 35 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"tagFormat": "v${version}",
"branches": [
"main"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/exec",
{
"verifyReleaseCmd": "sed -i \"s/.*__version__.*/__version__ = '${nextRelease.version}'/g\" betula/__init__.py && echo version=${nextRelease.version} >> $GITHUB_OUTPUT"
}
],
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md"
}
],
[
"@semantic-release/git",
{
"assets": [
"CHANGELOG.md",
"betula/__init__.py"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
[
"@semantic-release/github"
]
]
}
Loading

0 comments on commit 7b2417c

Please sign in to comment.