fix: Update workflow.yml #108
This file contains 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: Retrieve and Use Local Version | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
permissions: | |
contents: write | |
id-token: write | |
actions: write | |
packages: write | |
jobs: | |
release-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build twine setuptools_scm python-semantic-release | |
- name: Run semantic-release to determine version | |
id: determine_version | |
env: | |
GH_TOKEN: ${{ secrets.FOSS_GITHUB_TOKEN }} | |
run: | | |
VERSION=$(semantic-release version ) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
echo "Determined version: $VERSION" | |
- name: Create and push Git tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.FOSS_GITHUB_TOKEN }} | |
run: | | |
git config user.name "lakinmindfire" | |
git config user.email "lakin.mohapatra@mindfiresolutions.com" | |
git tag ${{ env.VERSION }} | |
git push origin ${{ env.VERSION }} | |
- name: Push changes to master using a personal access token | |
env: | |
GITHUB_TOKEN: ${{ secrets.FOSS_GITHUB_TOKEN }} # Use the PAT from a user with permissions | |
run: | | |
git config user.name "lakinmindfire" | |
git config user.email "lakin.mohapatra@mindfiresolutions.com" | |
git checkout master | |
git merge ${{ env.VERSION }} --no-ff | |
git push origin master | |
- name: Build package with semantic version | |
run: | | |
python setup.py sdist bdist_wheel | |
- name: Rename dist files with semantic version | |
run: | | |
for file in dist/*; do | |
mv "$file" "${file/.tar.gz/-${{ env.VERSION }}.tar.gz}" | |
mv "$file" "${file/.whl/-${{ env.VERSION }}.whl}" | |
done | |
- name: Publish package to PyPI | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
run: | | |
twine upload dist/* |