diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..12dd577 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,72 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + +jobs: + fmt: + name: cargo fmt + continue-on-error: true + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: dtolnay/rust-toolchain@1.91 + with: + components: rustfmt + - run: cargo fmt --all -- --check + + clippy: + name: cargo clippy + continue-on-error: true + runs-on: ubuntu-latest + env: + SQLX_OFFLINE: true + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: dtolnay/rust-toolchain@1.91 + with: + components: clippy + - uses: Swatinem/rust-cache@v2 + - run: cargo clippy --all-targets --all-features -- -D warnings + + test: + name: cargo test + continue-on-error: true + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: dtolnay/rust-toolchain@1.91 + - uses: Swatinem/rust-cache@v2 + - run: cargo test --all-targets --all-features + + integration: + name: integration tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - run: test/integration.sh diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml deleted file mode 100644 index 0a56947..0000000 --- a/.github/workflows/clippy.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Clippy - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - lint: - runs-on: ubuntu-latest - env: - SQLX_OFFLINE: true - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Clippy check lints - run: cargo clippy -- -D warnings - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ccdd248..2dac3b4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,19 +56,19 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: persist-credentials: false submodules: recursive - name: Install Rust - run: rustup update "1.88.0" --no-self-update && rustup default "1.88.0" + run: rustup update "1.91" --no-self-update && rustup default "1.91" - name: Install dist # we specify bash to get pipefail; it guards against the `curl` command # failing. otherwise `sh` won't catch that `curl` returned non-0 shell: bash - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.30.3/cargo-dist-installer.sh | sh" + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.31.0/cargo-dist-installer.sh | sh" - name: Cache dist - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: cargo-dist-cache path: ~/.cargo/bin/dist @@ -84,7 +84,7 @@ jobs: cat plan-dist-manifest.json echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT" - name: "Upload dist-manifest.json" - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: artifacts-plan-dist-manifest path: plan-dist-manifest.json @@ -118,7 +118,7 @@ jobs: - name: enable windows longpaths run: | git config --global core.longpaths true - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: persist-credentials: false submodules: recursive @@ -130,12 +130,12 @@ jobs: echo "$HOME/.cargo/bin" >> $GITHUB_PATH fi - name: Use rustup to set correct Rust version - run: rustup update "1.88.0" --no-self-update && rustup default "1.88.0" + run: rustup update "1.91" --no-self-update && rustup default "1.91" - name: Install dist run: ${{ matrix.install_dist.run }} # Get the dist-manifest - name: Fetch local artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v7 with: pattern: artifacts-* path: target/distrib/ @@ -162,7 +162,7 @@ jobs: cp dist-manifest.json "$BUILD_MANIFEST_NAME" - name: "Upload artifacts" - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: artifacts-build-local-${{ join(matrix.targets, '_') }} path: | @@ -179,21 +179,21 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: persist-credentials: false submodules: recursive - name: Install Rust - run: rustup update "1.88.0" --no-self-update && rustup default "1.88.0" + run: rustup update "1.91" --no-self-update && rustup default "1.91" - name: Install cached dist - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v7 with: name: cargo-dist-cache path: ~/.cargo/bin/ - run: chmod +x ~/.cargo/bin/dist # Get all the local artifacts for the global tasks to use (for e.g. checksums) - name: Fetch local artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v7 with: pattern: artifacts-* path: target/distrib/ @@ -211,7 +211,7 @@ jobs: cp dist-manifest.json "$BUILD_MANIFEST_NAME" - name: "Upload artifacts" - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: artifacts-build-global path: | @@ -231,21 +231,21 @@ jobs: outputs: val: ${{ steps.host.outputs.manifest }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: persist-credentials: false submodules: recursive - name: Install Rust - run: rustup update "1.88.0" --no-self-update && rustup default "1.88.0" + run: rustup update "1.91" --no-self-update && rustup default "1.91" - name: Install cached dist - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v7 with: name: cargo-dist-cache path: ~/.cargo/bin/ - run: chmod +x ~/.cargo/bin/dist # Fetch artifacts from scratch-storage - name: Fetch artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v7 with: pattern: artifacts-* path: target/distrib/ @@ -258,14 +258,14 @@ jobs: cat dist-manifest.json echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT" - name: "Upload dist-manifest.json" - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: # Overwrite the previous copy name: artifacts-dist-manifest path: dist-manifest.json # Create a GitHub Release while uploading all files to it - name: "Download GitHub Artifacts" - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v7 with: pattern: artifacts-* path: artifacts @@ -298,14 +298,14 @@ jobs: GITHUB_EMAIL: "admin+bot@axo.dev" if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: persist-credentials: true repository: "txpipe/homebrew-tap" token: ${{ secrets.HOMEBREW_TAP_TOKEN }} # So we have access to the formula - name: Fetch homebrew formulae - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v7 with: pattern: artifacts-* path: Formula/ @@ -332,20 +332,49 @@ jobs: done git push + publish-npm: + needs: + - plan + - host + runs-on: "ubuntu-22.04" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PLAN: ${{ needs.plan.outputs.val }} + if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }} + steps: + - name: Fetch npm packages + uses: actions/download-artifact@v7 + with: + pattern: artifacts-* + path: npm/ + merge-multiple: true + - uses: actions/setup-node@v6 + with: + node-version: '20.x' + registry-url: 'https://registry.npmjs.org' + - run: | + for release in $(echo "$PLAN" | jq --compact-output '.releases[] | select([.artifacts[] | endswith("-npm-package.tar.gz")] | any)'); do + pkg=$(echo "$release" | jq '.artifacts[] | select(endswith("-npm-package.tar.gz"))' --raw-output) + npm publish --access public "./npm/${pkg}" + done + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + announce: needs: - plan - host - publish-homebrew-formula + - publish-npm # use "always() && ..." to allow us to wait for all publish jobs while # still allowing individual publish jobs to skip themselves (for prereleases). # "host" however must run to completion, no skipping allowed! - if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') }} + if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') && (needs.publish-npm.result == 'skipped' || needs.publish-npm.result == 'success') }} runs-on: "ubuntu-22.04" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: persist-credentials: false submodules: recursive diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index fe27765..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Test - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - unit: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Run Unit Tests - run: cargo test - - integration: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Run Integration Tests - run: test/integration.sh diff --git a/Cargo.toml b/Cargo.toml index 714b6c8..f924a2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,11 +66,11 @@ lto = "thin" [workspace.metadata.release] push = false publish = false +tag-name = "v{{version}}" pre-release-hook = [ "git", "cliff", "-o", "CHANGELOG.md", - "--tag", - "{{version}}", + "--tag", "v{{version}}", ] diff --git a/dist-workspace.toml b/dist-workspace.toml index d25c292..59b7322 100644 --- a/dist-workspace.toml +++ b/dist-workspace.toml @@ -3,36 +3,24 @@ members = ["cargo:."] # Config for 'dist' [dist] -# The preferred dist version to use in CI (Cargo.toml SemVer syntax) -cargo-dist-version = "0.30.3" -# CI backends to support +cargo-dist-version = "0.31.0" ci = "github" -# The installers to generate for each app installers = ["shell", "powershell", "npm", "homebrew"] -# A GitHub repo to push Homebrew formulas to tap = "txpipe/homebrew-tap" -# Target platforms to build apps for (Rust target-triple syntax) targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"] -# Publish jobs to run in CI -publish-jobs = ["homebrew"] -# Which actions to run on pull requests +publish-jobs = ["homebrew", "npm"] +publish-prereleases = true pr-run-mode = "plan" -# Whether to install an updater program install-updater = false -# The preferred Rust toolchain to use in CI (rustup toolchain syntax) -rust-toolchain-version = "1.88.0" -# The archive format to use for windows builds (defaults .zip) +rust-toolchain-version = "1.91" windows-archive = ".tar.gz" -# The archive format to use for non-windows builds (defaults .tar.xz) unix-archive = ".tar.gz" -# A namespace to use when publishing this package to the npm registry npm-scope = "@txpipe" -# Path that installers should place binaries in install-path = "CARGO_HOME" [dist.github-custom-runners] global = "ubuntu-22.04" x86_64-unknown-linux-gnu = "ubuntu-22.04" -aarch64-apple-darwin = "macos-14" -x86_64-apple-darwin = "macos-13" +aarch64-apple-darwin = "macos-15" +x86_64-pc-windows-msvc = "windows-2022" aarch64-unknown-linux-gnu = "ubuntu-22.04-arm" diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..ff79a41 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.91" +components = ["rustfmt", "clippy"]