Single-source PHP SDK version from composer.json (#4) #63
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: build-release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Repo checkout | |
| uses: actions/checkout@v4 | |
| - name: Composer install | |
| uses: php-actions/composer@v6 | |
| - name: PHPStan check | |
| uses: php-actions/phpstan@v3 | |
| with: | |
| path: src/ | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: [build] | |
| permissions: | |
| contents: write | |
| outputs: | |
| new_version: ${{ steps.version.outputs.version }} | |
| released: ${{ steps.version.outputs.released }} | |
| steps: | |
| - name: Repo checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Resolve version | |
| id: version | |
| run: | | |
| VERSION=$(jq -r .version composer.json) | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| if git rev-parse "v$VERSION" >/dev/null 2>&1; then | |
| echo "released=false" >> "$GITHUB_OUTPUT" | |
| echo "Tag v$VERSION already exists — skipping release." | |
| else | |
| echo "released=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Create release | |
| if: steps.version.outputs.released == 'true' | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| tag: v${{ steps.version.outputs.version }} | |
| generateReleaseNotes: true |