Merge pull request #30 from mindfiredigital/master #11
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 and Publish Package | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - 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 python-semantic-release setuptools-scm | |
| - name: Create release branch | |
| run: | | |
| git config --global user.name "github-actions" | |
| git config --global user.email "github-actions@github.com" | |
| git checkout -b release-main | |
| git push --set-upstream origin release-main | |
| - name: Run semantic-release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| semantic-release version | |
| semantic-release publish | |
| - name: Push release branch | |
| run: git push origin release-main | |
| - name: Create PR to main | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh pr create \ | |
| --base main \ | |
| --head release-main \ | |
| --title "Automated Release Updates" \ | |
| --body "This pull request contains updates from the semantic-release process." || true | |
| - name: Build package | |
| run: python -m build | |
| - name: Publish package to PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: twine upload dist/* | |
| # create-pr-back-to-master: | |
| # needs: release | |
| # runs-on: ubuntu-latest | |
| # permissions: | |
| # contents: write | |
| # pull-requests: write | |
| # steps: | |
| # - name: Checkout code | |
| # uses: actions/checkout@v3 | |
| # with: | |
| # fetch-depth: 0 | |
| # ref: main | |
| # - name: Set Git Identity | |
| # run: | | |
| # git config --global user.name 'GitHub Actions' | |
| # git config --global user.email 'github-actions@github.com' | |
| # - name: Create Pull Request from main to master | |
| # env: | |
| # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # run: | | |
| # git fetch origin master:refs/remotes/origin/master | |
| # DIFF_COUNT=$(git rev-list --count origin/master..HEAD) | |
| # if [ "$DIFF_COUNT" -gt 0 ]; then | |
| # echo "Differences found between main and master. Creating PR..." | |
| # gh pr create \ | |
| # --base master \ | |
| # --head main \ | |
| # --title "Sync master with main after release" \ | |
| # --body "This is an automated PR to sync changes from main back to master after a release." || true | |
| # echo "Pull request created or already exists." | |
| # else | |
| # echo "No differences found between main and master. Skipping PR creation." | |
| # fi |