diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml deleted file mode 100644 index 9d3f161..0000000 --- a/.github/workflows/CI.yml +++ /dev/null @@ -1,190 +0,0 @@ -name: CI -env: - DEBUG: napi:* - APP_NAME: oxrls-native - MACOSX_DEPLOYMENT_TARGET: '10.13' - CARGO_INCREMENTAL: '1' -'on': - push: - branches: - - main - - 'release/*' - pull_request: null -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true -jobs: - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - name: Setup node - uses: actions/setup-node@v6 - with: - node-version: 24 - cache: yarn - - name: Install - uses: dtolnay/rust-toolchain@stable - with: - components: clippy, rustfmt - - name: Install dependencies - run: yarn install - - name: Oxlint - run: yarn lint - - name: Cargo fmt - run: cargo fmt -- --check - - name: Clippy - run: cargo clippy - build: - strategy: - fail-fast: false - matrix: - settings: - - host: macos-latest - target: x86_64-apple-darwin - build: yarn build --target x86_64-apple-darwin - - host: windows-latest - build: yarn build --target x86_64-pc-windows-msvc - target: x86_64-pc-windows-msvc - - host: ubuntu-latest - target: x86_64-unknown-linux-gnu - build: yarn build --target x86_64-unknown-linux-gnu --use-napi-cross - - host: macos-latest - target: aarch64-apple-darwin - build: yarn build --target aarch64-apple-darwin - name: stable - ${{ matrix.settings.target }} - node@22 - runs-on: ${{ matrix.settings.host }} - steps: - - uses: actions/checkout@v6 - - name: Setup node - uses: actions/setup-node@v6 - with: - node-version: 24 - cache: yarn - - name: Install - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - targets: ${{ matrix.settings.target }} - - name: Cache cargo - uses: actions/cache@v5 - with: - path: | - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - ~/.napi-rs - .cargo-cache - target/ - key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }} - - uses: mlugg/setup-zig@v2 - if: ${{ contains(matrix.settings.target, 'musl') }} - with: - version: 0.14.1 - - name: Install cargo-zigbuild - uses: taiki-e/install-action@v2 - if: ${{ contains(matrix.settings.target, 'musl') }} - env: - GITHUB_TOKEN: ${{ github.token }} - with: - tool: cargo-zigbuild - - name: Setup toolchain - run: ${{ matrix.settings.setup }} - if: ${{ matrix.settings.setup }} - shell: bash - - name: Install dependencies - run: yarn install - - name: Build - run: ${{ matrix.settings.build }} - shell: bash - - name: Build oxrls CLI - run: cargo build --release --bin oxrls - shell: bash - - name: Upload NAPI artifact - uses: actions/upload-artifact@v7 - with: - name: bindings-${{ matrix.settings.target }} - path: | - ${{ env.APP_NAME }}.*.node - ${{ env.APP_NAME }}.*.wasm - if-no-files-found: error - - name: Upload oxrls binary - uses: actions/upload-artifact@v7 - with: - name: oxrls-${{ matrix.settings.target }} - path: target/release/oxrls* - if-no-files-found: error - test: - name: cargo test - ${{ matrix.settings.target }} - needs: - - build - strategy: - fail-fast: false - matrix: - settings: - - host: windows-latest - target: x86_64-pc-windows-msvc - - host: macos-latest - target: aarch64-apple-darwin - - host: macos-latest - target: x86_64-apple-darwin - - host: ubuntu-latest - target: x86_64-unknown-linux-gnu - runs-on: ${{ matrix.settings.host }} - steps: - - uses: actions/checkout@v6 - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - targets: ${{ matrix.settings.target }} - - name: Cache cargo - uses: actions/cache@v5 - with: - path: | - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ matrix.settings.target }}-test-${{ matrix.settings.host }} - - name: Run tests - run: cargo test - publish: - name: Publish - if: startsWith(github.ref, 'refs/heads/release/') - runs-on: ubuntu-latest - permissions: - id-token: write - needs: - - lint - - test - steps: - - uses: actions/checkout@v6 - - name: Setup node - uses: actions/setup-node@v6 - with: - node-version: 24 - cache: yarn - - name: Install dependencies - run: yarn install - - name: create npm dirs - run: yarn napi create-npm-dirs - - name: Download all artifacts - uses: actions/download-artifact@v8 - with: - path: artifacts - - name: Move artifacts - run: yarn artifacts - - name: Determine version and tag - run: | - VERSION=$(node -p "require('./package.json').version") - NPM_TAG="${GITHUB_REF_NAME#release/}" - echo "VERSION=$VERSION" >> $GITHUB_ENV - echo "NPM_TAG=$NPM_TAG" >> $GITHUB_ENV - - name: Publish to npm - run: | - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc - npm publish --access public --tag ${{ env.NPM_TAG }} - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.tangled/workflows/ci.yml b/.tangled/workflows/ci.yml new file mode 100644 index 0000000..bcf6481 --- /dev/null +++ b/.tangled/workflows/ci.yml @@ -0,0 +1,66 @@ +when: + - event: ["push", "manual"] + branch: ["main", "release/*"] + - event: ["pull_request"] + branch: ["main"] + +engine: "nixery" + +dependencies: + nixpkgs/nixpkgs-unstable: + - nodejs_24 + - yarn + - zig + - llvm + - rustup + - cargo-zigbuild + - cargo-xwin + +environment: + CI: "true" + +steps: + - name: "Install Node dependencies" + command: yarn install + + - name: "Install Rust targets" + command: | + rustup target add \ + x86_64-apple-darwin \ + aarch64-apple-darwin \ + x86_64-pc-windows-msvc + + - name: "Lint" + command: | + cargo fmt -- --check + cargo clippy + + - name: "Build Linux x64" + command: npx napi build --target x86_64-unknown-linux-gnu --release --use-napi-cross + + - name: "Build Windows x64" + command: npx napi build --target x86_64-pc-windows-msvc --release -x + + - name: "Build macOS x64" + command: npx napi build --target x86_64-apple-darwin --release -x + + - name: "Build macOS ARM64" + command: npx napi build --target aarch64-apple-darwin --release -x + + - name: "Build CLI" + command: cargo build --release --bin oxrls + + - name: "Test" + command: cargo test + + - name: "Publish (release/* only)" + command: | + if [ "$TANGLED_REF_TYPE" = "branch" ] && [[ "$TANGLED_REF_NAME" == release/* ]]; then + npx napi create-npm-dirs + cp oxrls-native.linux-x64-gnu.node npm/linux-x64-gnu/ + cp target/x86_64-apple-darwin/release/liboxrls.dylib npm/darwin-x64/oxrls-native.darwin-x64.node + cp target/aarch64-apple-darwin/release/liboxrls.dylib npm/darwin-arm64/oxrls-native.darwin-arm64.node + cp target/x86_64-pc-windows-msvc/release/oxrls.dll npm/win32-x64-msvc/oxrls-native.win32-x64-msvc.node + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc + npm publish --access public --tag "${TANGLED_REF_NAME#release/}" + fi diff --git a/Cargo.toml b/Cargo.toml index eb596d7..fa4907b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ thiserror = "2" inquire = "0.7" rand = "0.8" indexmap = { version = "2", features = ["serde"] } -chrono = "0.4" +time = { version = "0.3", features = ["formatting"] } [dev-dependencies] tempfile = "3" diff --git a/src/changelog.rs b/src/changelog.rs index 16566b3..9de9216 100644 --- a/src/changelog.rs +++ b/src/changelog.rs @@ -134,11 +134,15 @@ pub fn group_changes_by_type( pub fn generate_global_changelog_section( packages: &[(String, semver::Version, BumpType, Vec)], ) -> String { - use chrono::Utc; + use time::OffsetDateTime; let mut lines = Vec::new(); - let date_str = Utc::now().format("%Y-%m-%d").to_string(); + let date_format = + time::format_description::parse("[year]-[month]-[day]").expect("valid date format"); + let date_str = OffsetDateTime::now_utc() + .format(&date_format) + .expect("valid date"); lines.push(format!("## {}", date_str)); lines.push(String::new());