chore(core): prepare 0.6.0 release credit #9
Workflow file for this run
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: | |
| tags: | |
| - 'v*.*.*' | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| # Build binaries for all platforms | |
| build: | |
| name: Build (${{ matrix.target }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| archive: tar.gz | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| archive: tar.gz | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| archive: tar.gz | |
| - target: x86_64-pc-windows-msvc | |
| os: windows-latest | |
| archive: zip | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ matrix.target }} | |
| - name: Build release binary | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Prepare artifact (Unix) | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| strip tsql || true | |
| tar czf ../../../tsql-${{ matrix.target }}.tar.gz tsql | |
| cd ../../.. | |
| - name: Prepare artifact (Windows) | |
| if: matrix.os == 'windows-latest' | |
| shell: pwsh | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| Compress-Archive -Path tsql.exe -DestinationPath ../../../tsql-${{ matrix.target }}.zip | |
| cd ../../.. | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: tsql-${{ matrix.target }} | |
| path: tsql-${{ matrix.target }}.${{ matrix.archive }} | |
| if-no-files-found: error | |
| # Create GitHub Release | |
| release: | |
| name: Create Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Prepare release assets | |
| run: | | |
| mkdir -p release | |
| find artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec mv {} release/ \; | |
| cd release | |
| sha256sum * > SHA256SUMS.txt | |
| cat SHA256SUMS.txt | |
| - name: Generate release notes | |
| uses: orhun/git-cliff-action@v4 | |
| with: | |
| config: cliff.toml | |
| args: --current --github-repo ${{ github.repository }} | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| env: | |
| OUTPUT: RELEASE_NOTES.md | |
| GITHUB_REPO: ${{ github.repository }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: release/* | |
| body_path: RELEASE_NOTES.md | |
| draft: false | |
| prerelease: ${{ contains(github.ref, '-rc') || contains(github.ref, '-beta') || contains(github.ref, '-alpha') }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Publish to crates.io | |
| publish: | |
| name: Publish to crates.io | |
| needs: release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Publish tui-syntax | |
| run: cargo publish -p tui-syntax --token ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| continue-on-error: true # May already be published | |
| - name: Wait for crates.io index | |
| run: | | |
| VERSION=$(cargo metadata --no-deps --format-version 1 | python3 -c 'import json, sys; print(next(p["version"] for p in json.load(sys.stdin)["packages"] if p["name"] == "tui-syntax"))') | |
| for _ in {1..20}; do | |
| if cargo search tui-syntax --limit 1 | grep -q "tui-syntax = \"$VERSION\""; then | |
| exit 0 | |
| fi | |
| sleep 15 | |
| done | |
| echo "tui-syntax $VERSION did not appear in the crates.io index in time" >&2 | |
| exit 1 | |
| - name: Publish tsql | |
| run: cargo publish -p tsql --token ${{ secrets.CARGO_REGISTRY_TOKEN }} |