|
| 1 | +name: Release Alpha and Propose Stable |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [closed] |
| 6 | + branches: [dev] |
| 7 | + |
| 8 | +jobs: |
| 9 | + publish_alpha: |
| 10 | + if: github.event.pull_request.merged == true |
| 11 | + uses: TigreGotico/gh-automations/.github/workflows/publish-alpha.yml@master |
| 12 | + secrets: inherit |
| 13 | + with: |
| 14 | + branch: 'dev' |
| 15 | + version_file: 'hivemind_sqlite_database/version.py' |
| 16 | + setup_py: 'setup.py' |
| 17 | + update_changelog: true |
| 18 | + publish_prerelease: true |
| 19 | + changelog_max_issues: 100 |
| 20 | + |
| 21 | + notify: |
| 22 | + if: github.event.pull_request.merged == true |
| 23 | + needs: publish_alpha |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v2 |
| 27 | + - name: Send message to Matrix bots channel |
| 28 | + id: matrix-chat-message |
| 29 | + |
| 30 | + with: |
| 31 | + homeserver: 'matrix.org' |
| 32 | + token: ${{ secrets.MATRIX_TOKEN }} |
| 33 | + channel: '!WjxEKjjINpyBRPFgxl:krbel.duckdns.org' |
| 34 | + message: | |
| 35 | + new ${{ github.event.repository.name }} PR merged! https://github.com/${{ github.repository }}/pull/${{ github.event.number }} |
| 36 | +
|
| 37 | + publish_pypi: |
| 38 | + needs: publish_alpha |
| 39 | + if: success() # Ensure this job only runs if the previous job succeeds |
| 40 | + runs-on: ubuntu-latest |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v2 |
| 43 | + with: |
| 44 | + ref: dev |
| 45 | + fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. |
| 46 | + - name: Setup Python |
| 47 | + uses: actions/setup-python@v1 |
| 48 | + with: |
| 49 | + python-version: 3.8 |
| 50 | + - name: Install Build Tools |
| 51 | + run: | |
| 52 | + python -m pip install build wheel |
| 53 | + - name: version |
| 54 | + run: echo "::set-output name=version::$(python setup.py --version)" |
| 55 | + id: version |
| 56 | + - name: Build Distribution Packages |
| 57 | + run: | |
| 58 | + python setup.py sdist bdist_wheel |
| 59 | + - name: Publish to PyPI |
| 60 | + uses: pypa/gh-action-pypi-publish@master |
| 61 | + with: |
| 62 | + password: ${{secrets.PYPI_TOKEN}} |
| 63 | + |
| 64 | + |
| 65 | + propose_release: |
| 66 | + needs: publish_alpha |
| 67 | + if: success() # Ensure this job only runs if the previous job succeeds |
| 68 | + runs-on: ubuntu-latest |
| 69 | + steps: |
| 70 | + - name: Checkout dev branch |
| 71 | + uses: actions/checkout@v3 |
| 72 | + with: |
| 73 | + ref: dev |
| 74 | + |
| 75 | + - name: Setup Python |
| 76 | + uses: actions/setup-python@v2 |
| 77 | + with: |
| 78 | + python-version: '3.10' |
| 79 | + |
| 80 | + - name: Get version from setup.py |
| 81 | + id: get_version |
| 82 | + run: | |
| 83 | + VERSION=$(python setup.py --version) |
| 84 | + echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 85 | +
|
| 86 | + - name: Create and push new branch |
| 87 | + run: | |
| 88 | + git checkout -b release-${{ env.VERSION }} |
| 89 | + git push origin release-${{ env.VERSION }} |
| 90 | +
|
| 91 | + - name: Open Pull Request from dev to master |
| 92 | + env: |
| 93 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + run: | |
| 95 | + # Variables |
| 96 | + BRANCH_NAME="release-${{ env.VERSION }}" |
| 97 | + BASE_BRANCH="master" |
| 98 | + HEAD_BRANCH="release-${{ env.VERSION }}" |
| 99 | + PR_TITLE="Release ${{ env.VERSION }}" |
| 100 | + PR_BODY="Human review requested!" |
| 101 | +
|
| 102 | + # Create a PR using GitHub API |
| 103 | + curl -X POST \ |
| 104 | + -H "Accept: application/vnd.github+json" \ |
| 105 | + -H "Authorization: token $GITHUB_TOKEN" \ |
| 106 | + -d "{\"title\":\"$PR_TITLE\",\"body\":\"$PR_BODY\",\"head\":\"$HEAD_BRANCH\",\"base\":\"$BASE_BRANCH\"}" \ |
| 107 | + https://api.github.com/repos/${{ github.repository }}/pulls |
| 108 | +
|
0 commit comments