test: Merge pull request #177 from bensteUEM/bensteUEM/issue154 #125
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: 1. Release-Please | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| upload_url: ${{ steps.release.outputs.upload_url }} | |
| version: ${{ steps.release.outputs.version }} | |
| tag_name: ${{ steps.release.outputs.tag_name }} | |
| release_created: ${{ steps.release.outputs.release_created }} | |
| steps: | |
| - id: release | |
| uses: googleapis/release-please-action@v4 | |
| with: | |
| token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }} | |
| config-file: .release-please-config.json | |
| manifest-file: .release-please-manifest.json | |
| - name: Debug release outputs | |
| run: | | |
| echo "release_created=${{ steps.release.outputs.release_created }}" | |
| echo "version=${{ steps.release.outputs.version }}" | |
| echo "tag_name=${{ steps.release.outputs.tag_name }}" | |
| echo "upload_url=${{ steps.release.outputs.upload_url }}" | |
| upload-assets: | |
| runs-on: ubuntu-latest | |
| needs: release | |
| if: needs.release.outputs.release_created == 'true' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4.2.1 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5.2.0 | |
| with: | |
| python-version: 3.x | |
| - name: Install Poetry | |
| run: | | |
| pip install poetry | |
| poetry config virtualenvs.create false # Skip creating a virtual environment | |
| env: | |
| POETRY_HOME: ${{ github.workspace }}/.poetry | |
| - name: Install project dependencies | |
| run: poetry install | |
| env: | |
| POETRY_HOME: ${{ github.workspace }}/.poetry | |
| - name: Build package | |
| run: poetry build | |
| env: | |
| POETRY_HOME: ${{ github.workspace }}/.poetry | |
| - name: Set up GitHub CLI | |
| uses: cli/gh-action@v2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload dist/* to release | |
| run: | | |
| release_id=$(gh api \ | |
| -H "Accept: application/vnd.github+json" \ | |
| /repos/${{ github.repository }}/releases/tags/${{ needs.release.outputs.tag_name }} \ | |
| --jq .id) | |
| for file in dist/*; do | |
| echo "Uploading $file" | |
| gh api \ | |
| --method POST \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Content-Type: application/octet-stream" \ | |
| "/repos/${{ github.repository }}/releases/$release_id/assets?name=$(basename "$file")" \ | |
| --input "$file" | |
| done | |
| - name: Append custom release notes | |
| run: | | |
| release_id=$(gh api \ | |
| -H "Accept: application/vnd.github+json" \ | |
| /repos/${{ github.repository }}/releases/tags/${{ needs.release.outputs.tag_name }} \ | |
| --jq .id) | |
| # Fetch existing release body | |
| existing_body=$(gh api /repos/${{ github.repository }}/releases/$release_id --jq .body) | |
| # Create temporary file for new body | |
| tmpfile=$(mktemp) | |
| # Write combined content into the file | |
| { | |
| echo "$existing_body" | |
| echo | |
| echo "Automated Release preparation using Git Tag" | |
| echo " - make sure tests didn't fail" | |
| echo " - needs to be published from draft online" | |
| echo | |
| echo "Install as package using:" | |
| echo '```bash' | |
| echo "pip install git+https://github.com/bensteUEM/ChurchToolsAPI.git@${{ needs.release.outputs.version }}#egg=churchtools-api" | |
| echo '```' | |
| } > "$tmpfile" | |
| # Update the release body using the file | |
| gh api \ | |
| -X PATCH \ | |
| -H "Accept: application/vnd.github+json" \ | |
| /repos/${{ github.repository }}/releases/$release_id \ | |
| -F body="$(cat "$tmpfile")" |