cd-publish-release #975
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: cd-publish-release | |
| on: | |
| schedule: | |
| - cron: "*/5 * * * *" | |
| workflow_dispatch: | |
| permissions: | |
| actions: write | |
| contents: write | |
| concurrency: | |
| group: cd-publish-release-main | |
| cancel-in-progress: true | |
| jobs: | |
| publish-release: | |
| runs-on: blacksmith-2vcpu-ubuntu-2404 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Read current version | |
| id: version | |
| run: | | |
| VERSION=$(node -e "const fs=require('node:fs');const pkg=JSON.parse(fs.readFileSync('package.json','utf8'));process.stdout.write(String(pkg.version ?? ''));") | |
| if [ -z "$VERSION" ]; then | |
| echo "package.json version is empty" | |
| exit 1 | |
| fi | |
| echo "value=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Skip if release already exists | |
| id: release_exists | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="v${{ steps.version.outputs.value }}" | |
| if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| echo "Release $TAG already exists; skipping." | |
| else | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Create GitHub release and tag | |
| if: steps.release_exists.outputs.skip != 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="v${{ steps.version.outputs.value }}" | |
| gh release create "$TAG" \ | |
| --repo "$GITHUB_REPOSITORY" \ | |
| --title "Release $TAG" \ | |
| --generate-notes \ | |
| --target "$GITHUB_SHA" | |
| - name: Trigger TUI release bundle workflow | |
| if: steps.release_exists.outputs.skip != 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="v${{ steps.version.outputs.value }}" | |
| gh workflow run tui-release \ | |
| --repo "$GITHUB_REPOSITORY" \ | |
| --ref "$TAG" |