|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + version: |
| 10 | + description: 'Version to release (optional)' |
| 11 | + required: false |
| 12 | + type: string |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: release-${{ github.workflow }}-${{ github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: write |
| 20 | + pull-requests: read |
| 21 | + statuses: write |
| 22 | + |
| 23 | +jobs: |
| 24 | + continuous: |
| 25 | + name: Continuous |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + - name: Determine version |
| 30 | + id: get_version |
| 31 | + run: | |
| 32 | + if [ -n "${{ github.event.inputs.version }}" ]; then |
| 33 | + echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT |
| 34 | + else |
| 35 | + echo "No version provided, calculating next version..." |
| 36 | + fi |
| 37 | + - name: Calculate next version |
| 38 | + if: steps.get_version.outputs.VERSION == '' |
| 39 | + uses: ietf-tools/semver-action@v1 |
| 40 | + id: semver |
| 41 | + with: |
| 42 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + branch: main |
| 44 | + - name: Set final version |
| 45 | + id: set_version |
| 46 | + run: | |
| 47 | + if [ -n "${{ steps.get_version.outputs.VERSION }}" ]; then |
| 48 | + echo "version=${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_OUTPUT |
| 49 | + else |
| 50 | + echo "version=${{ steps.semver.outputs.next }}" >> $GITHUB_OUTPUT |
| 51 | + fi |
| 52 | + - name: "Generate Tuist Changelog" |
| 53 | + id: changelog |
| 54 | + uses: mikepenz/release-changelog-builder-action@v2 |
| 55 | + with: |
| 56 | + owner: "tuist" |
| 57 | + repo: "XcodeGraph" |
| 58 | + configuration: ".github/changelog-configuration.json" |
| 59 | + - name: Check if there are categorized PRs |
| 60 | + id: check_prs |
| 61 | + run: | |
| 62 | + if [ "${{ steps.changelog.outputs.categorized_prs }}" = "0" ]; then |
| 63 | + echo "skip_next_steps=true" >> $GITHUB_OUTPUT |
| 64 | + else |
| 65 | + echo "skip_next_steps=false" >> $GITHUB_OUTPUT |
| 66 | + fi |
| 67 | + - name: Update Changelog |
| 68 | + uses: stefanzweifel/changelog-updater-action@v1 |
| 69 | + if: steps.check_prs.outputs.skip_next_steps != 'true' |
| 70 | + with: |
| 71 | + latest-version: ${{ steps.set_version.outputs.version }} |
| 72 | + release-notes: ${{ steps.changelog.outputs.changelog }} |
| 73 | + path-to-changelog: CHANGELOG.md |
| 74 | + - uses: stefanzweifel/git-auto-commit-action@v5 |
| 75 | + if: steps.check_prs.outputs.skip_next_steps != 'true' |
| 76 | + with: |
| 77 | + commit_message: "Version ${{ steps.set_version.outputs.version }}" |
| 78 | + tagging_message: ${{ steps.set_version.outputs.version }} |
| 79 | + commit_options: '--allow-empty' |
| 80 | + - name: Create GitHub Release on the tuist/XcodeGraph repository |
| 81 | + if: steps.check_prs.outputs.skip_next_steps != 'true' |
| 82 | + uses: softprops/action-gh-release@v1 |
| 83 | + with: |
| 84 | + draft: false |
| 85 | + repository: tuist/XcodeGraph |
| 86 | + name: ${{ steps.set_version.outputs.version }} |
| 87 | + tag_name: ${{ steps.set_version.outputs.version }} |
| 88 | + body: ${{ steps.changelog.outputs.changelog }} |
0 commit comments