fix(redirect): suppress stderr from builtins with 2>/dev/null (#1138) #648
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: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| actions: write | |
| jobs: | |
| release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| # Only run if manually triggered OR commit message starts with "chore(release): prepare v" | |
| if: "${{ github.event_name == 'workflow_dispatch' || startsWith(github.event.head_commit.message, 'chore(release): prepare v') }}" | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Extract version | |
| id: version | |
| env: | |
| EVENT_NAME: ${{ github.event_name }} | |
| COMMIT_MSG: ${{ github.event.head_commit.message }} | |
| run: | | |
| if [ "$EVENT_NAME" = "workflow_dispatch" ]; then | |
| # Manual trigger: read version from Cargo.toml | |
| VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/') | |
| else | |
| # Push trigger: extract from first line of commit message | |
| FIRST_LINE=$(echo "$COMMIT_MSG" | head -1) | |
| VERSION=$(echo "$FIRST_LINE" | sed -n 's/.*prepare v\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p') | |
| fi | |
| if [ -z "$VERSION" ]; then | |
| echo "Error: Could not determine version" | |
| exit 1 | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "tag=v$VERSION" >> $GITHUB_OUTPUT | |
| echo "Detected version: $VERSION" | |
| - name: Verify version matches Cargo.toml | |
| run: | | |
| CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/') | |
| if [ "${{ steps.version.outputs.version }}" != "$CARGO_VERSION" ]; then | |
| echo "Error: Commit version (${{ steps.version.outputs.version }}) does not match Cargo.toml version ($CARGO_VERSION)" | |
| exit 1 | |
| fi | |
| echo "Version verified: $CARGO_VERSION" | |
| - name: Extract release notes from CHANGELOG | |
| id: changelog | |
| run: | | |
| # Extract the section for this version from CHANGELOG.md | |
| VERSION="${{ steps.version.outputs.version }}" | |
| # Get content between this version header and the next version header (or end) | |
| NOTES=$(awk "/^## \[$VERSION\]/{found=1; next} /^## \[/{if(found) exit} found{print}" CHANGELOG.md) | |
| # Write to file to preserve newlines | |
| echo "$NOTES" > release_notes.md | |
| echo "Release notes extracted for v$VERSION" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.tag }} | |
| name: Release ${{ steps.version.outputs.tag }} | |
| body_path: release_notes.md | |
| draft: false | |
| prerelease: false | |
| # Note: the `release: [published]` event does NOT trigger other | |
| # workflows when the release is created with GITHUB_TOKEN (GitHub | |
| # prevents recursive workflow triggers). We must dispatch explicitly. | |
| # Use --ref to set GITHUB_REF to the tag so publish-js correctly | |
| # identifies stable releases. | |
| - name: Trigger publish workflows | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="${{ steps.version.outputs.tag }}" | |
| gh workflow run publish.yml --ref "$TAG" | |
| gh workflow run publish-python.yml --ref "$TAG" | |
| gh workflow run publish-js.yml --ref "$TAG" | |
| - name: Trigger CLI binary builds for release tag | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="v${{ steps.version.outputs.version }}" | |
| echo "Triggering CLI binary builds for tag $TAG..." | |
| gh workflow run cli-binaries.yml --ref "$TAG" -f "tag=$TAG" | |
| echo "CLI binary builds triggered for $TAG" |