name: Create Release concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true on: workflow_dispatch: push: branches: - main paths-ignore: - '**/*.md' permissions: contents: write pull-requests: write actions: read pages: write id-token: write env: APP_NAME: pyTermTk APP_TTK: libs/pyTermTk jobs: release-please: # runs-on: ubuntu-latest runs-on: self-hosted outputs: rp_out: ${{ toJson(steps.release-please.outputs) }} matrix: ${{ steps.set-matrix.outputs.matrix }} matrix-pypi: ${{ steps.set-matrix.outputs.matrix_pypi }} matrix-itch: ${{ steps.set-matrix.outputs.matrix_itch }} steps: - uses: actions/checkout@v4 with: ref: ${{ github.sha }} - name: Trust git directory run: git config --global --add safe.directory $GITHUB_WORKSPACE - uses: googleapis/release-please-action@v4 timeout-minutes: 15 id: release-please with: token: ${{ secrets.GH_PAT_TOKEN }} config-file: .release-please-config.json manifest-file: .release-please-manifest.json - name: Print outputs shell: bash env: OUTPUTS: ${{ toJSON(steps.release-please.outputs) }} run: | echo OUTPUTS: "$OUTPUTS" - name: Set up Python 3.11 uses: actions/setup-python@v5 with: python-version: '3.11' - name: Update Version if: ${{ steps.release-please.outputs.prs_created == 'true'}} shell: bash env: GITHUB_TOKEN: ${{ secrets.GH_PAT_TOKEN }} RP_OUT: ${{ toJson(steps.release-please.outputs) }} run: | _get_name(){ _ITEM=$1 jq -r ".packages[\"${_ITEM}\"][\"package-name\"]" .release-please-config.json } _get_version(){ _ITEM=$1 jq -r ".[\"${_ITEM}\"]" .release-please-manifest.json } echo '::group::Setup Git' git config --global user.name 'Eugenio Parodi - Action' git config --global user.email 'ceccopierangioliegenio@googlemail.com' git clone \ -b ${{ fromJson(steps.release-please.outputs.pr).headBranchName }} \ https://${GITHUB_TOKEN}@github.com/ceccopierangiolieugenio/pyTermTk.git \ pyTermTk.new echo '::endgroup::' cd pyTermTk.new echo '::group::🍧 Print the Versions' release-helper \ --config .release-please-config.json \ --manifest .release-please-manifest.json \ info <<< '{}' echo '::endgroup::' echo '::group::🍓 Update the Versions' _VERSION_TTK=$(_get_name ${APP_TTK}) sed -i \ "s|__version__:str.*|__version__:str = '${_VERSION_TTK}'|" \ libs/pyTermTk/TermTk/__init__.py release-helper \ --config .release-please-config.json \ --manifest .release-please-manifest.json \ upgrade <<< ${RP_OUT} cp libs/pyTermTk/CHANGELOG.md CHANGELOG.md echo '::endgroup::' echo '::group::Push the Versions' git add \ apps/*/*/__init__.py \ libs/pyTermTk/TermTk/__init__.py \ CHANGELOG.md find . -name pyproject.toml | xargs git add if [[ $(git status --porcelain) ]] ; then git commit -m "chore: updated TermTk and apps to versions" git push fi echo '::endgroup::' - name: Define the Matrix strategy id: set-matrix env: RP_OUT: ${{ toJson(steps.release-please.outputs) }} run: | echo "matrix<<_EOF" >> $GITHUB_OUTPUT release-helper \ --config .release-please-config.json \ --manifest .release-please-manifest.json \ matrix all <<< ${RP_OUT} >> $GITHUB_OUTPUT echo "_EOF" >> $GITHUB_OUTPUT echo "matrix_itch<<_EOF" >> $GITHUB_OUTPUT release-helper \ --config .release-please-config.json \ --manifest .release-please-manifest.json \ matrix itch <<< ${RP_OUT} >> $GITHUB_OUTPUT echo "_EOF" >> $GITHUB_OUTPUT echo "matrix_pypi<<_EOF" >> $GITHUB_OUTPUT release-helper \ --config .release-please-config.json \ --manifest .release-please-manifest.json \ matrix pypi <<< ${RP_OUT} >> $GITHUB_OUTPUT echo "_EOF" >> $GITHUB_OUTPUT pyTermTk-deploy-artifacts: if: ${{ fromJson(needs.release-please.outputs.rp_out)['libs/pyTermTk--release_created'] }} # runs-on: ubuntu-latest runs-on: self-hosted name: Deploy pyTermTk to github release needs: release-please steps: - uses: actions/checkout@v4 with: ref: ${{ github.sha }} - name: Create Artifacts id: create-artifacts shell: bash run: | # _TMP=$(mktmp) _TMP=tmp echo "artifacts_dir=${_TMP}" >> $GITHUB_OUTPUT mkdir -p ${_TMP} find libs/pyTermTk/TermTk -name "*.py" | sed 's,libs/pyTermTk/,,' | sort | xargs tar cvzf ${_TMP}/TermTk.tgz -C libs/pyTermTk find tutorial -name '*.py' -o -name '*.json' | sort | xargs tar cvzf ${_TMP}/tutorial.tgz find \ demo/paint.py \ demo/ttkode.py \ demo/demo.py \ demo/showcase/*.* | sort | xargs tar cvzf ${_TMP}/demo.tgz find \ tests/ansi.images.json \ tests/t.ui/*.* | sort | xargs tar cvzf ${_TMP}/tests.tgz - name: Upload artifatcs to Release shell: bash env: GITHUB_TOKEN: ${{ secrets.GH_PAT_TOKEN }} TAG_NAME: ${{ fromJson(needs.release-please.outputs.rp_out)['libs/pyTermTk--tag_name'] }} run: | _TMP=${{ steps.create-artifacts.outputs.artifacts_dir }} gh release upload ${TAG_NAME} ${_TMP}/TermTk.tgz gh release upload ${TAG_NAME} ${_TMP}/tutorial.tgz gh release upload ${TAG_NAME} ${_TMP}/tests.tgz gh release upload ${TAG_NAME} ${_TMP}/demo.tgz rm -rf ${_TMP} pyTermTk-deploy-sandbox: name: Deploy pyTermTk Sandbox uses: ./.github/workflows/release-sandbox.yml needs: release-please secrets: inherit pyTermTk-deploy-sandbox-bin: if: ${{ fromJson(needs.release-please.outputs.rp_out)['libs/pyTermTk--release_created'] }} name: Deploy pyTermTk Sandbox Binaries uses: ./.github/workflows/release-sandbox-bin.yml needs: - release-please - pyTermTk-deploy-artifacts secrets: inherit pyTermTk-deploy-docs: if: ${{ fromJson(needs.release-please.outputs.rp_out)['libs/pyTermTk--release_created'] }} name: Deploy pyTermTk Docs uses: ./.github/workflows/release-doc.yml needs: - release-please - pyTermTk-deploy-artifacts secrets: inherit publish-pypi: if: ${{ needs.release-please.outputs.matrix-pypi != '[]' }} name: Publish pypi ${{ matrix.name }} needs: - release-please strategy: matrix: include: ${{ fromJson(needs.release-please.outputs.matrix-pypi) }} uses: ./.github/workflows/python-publish.yml with: pkg_name: ${{ matrix.name }} pkg_folder: ${{ matrix.path }} secrets: inherit # publish-itch: # name: Publish Itch ${{ matrix.name }} # needs: # - release-please # - generate-matrix # runs-on: self-hosted # strategy: # matrix: # include: ${{ fromJson(needs.generate-matrix.outputs.matrix-itch) }} # steps: # - name: Build ${{ matrix.name }} # run: | # echo "Building ${{ matrix.name }} at path: ${{ matrix.path }}" # uses: ./.github/workflows/itch-publish.yml # with: # pkg_name: dumb-paint-tool publish-dumbPaintTool-itch: if: ${{ fromJson(needs.release-please.outputs.rp_out)['apps/dumbPaintTool--release_created'] }} name: Publish dumbPaintTool on itch.io uses: ./.github/workflows/itch-publish.yml with: pkg_name: dumb-paint-tool needs: - release-please secrets: inherit notify: if: ${{ needs.release-please.outputs.matrix != '[]' }} name: Notify ${{ matrix.name }} to the socials needs: - release-please runs-on: self-hosted strategy: matrix: include: ${{ fromJson(needs.release-please.outputs.matrix) }} steps: - uses: actions/checkout@v4 with: ref: ${{ github.sha }} - name: Set up Python 3.11 uses: actions/setup-python@v5 with: python-version: '3.11' - name: Install dependencies shell: bash run: pip install -e 'tools/ci[social]' - name: Notify ${{ matrix.name }} on Discord env: RN: ${{ matrix.release-notes }} MESSAGE: ${{ matrix.release-notes }} DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }} run: | notify-discord ${{ matrix.name }} v${{ matrix.version }} - name: Notify ${{ matrix.name }} on Github Discussion env: RN: ${{ matrix.release-notes }} MESSAGE: ${{ matrix.release-notes }} GITHUB_TOKEN: ${{ secrets.GH_PAT_TOKEN }} GH_DISCUSSION_TOKEN: ${{ secrets.GH_DISCUSSION_TOKEN }} run: | notify-gh-discussion ${{ matrix.name }} v${{ matrix.version }} - name: Notify ${{ matrix.name }} on Bluesky env: BLUESKY_APP_PWD: ${{ secrets.BLUESKY_APP_PWD }} BLUESKY_APP_IDENTIFIER: ${{ secrets.BLUESKY_APP_IDENTIFIER }} run: | notify-bluesky ${{ matrix.name }} v${{ matrix.version }} - name: Notify ${{ matrix.name }} on Twitter env: X_API_KEY: ${{ secrets.X_API_KEY }} X_API_SECRET: ${{ secrets.X_API_SECRET }} X_ACCESS_TOKEN: ${{ secrets.X_ACCESS_TOKEN }} X_ACCESS_TOKEN_SECRET: ${{ secrets.X_ACCESS_TOKEN_SECRET }} run: | notify-twitter ${{ matrix.name }} ${{ matrix.version }}