-
Notifications
You must be signed in to change notification settings - Fork 2
Publish percent-encoding-iri and optional IRI percent-encoding #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
eda15ef
4a04d9c
e79448a
67ee9ac
c42f625
21300cd
880df2b
5486038
095cc10
a9f979d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # Publish https://crates.io/crates/percent-encoding-iri | ||
| # | ||
| # Prerequisites: | ||
| # - GitHub secret CARGO_REGISTRY_TOKEN (https://crates.io/settings/tokens) with publish scope. | ||
| # - Optional: create Environment "crates-io" (Settings → Environments), restrict to `main`, | ||
| # and add required reviewers so only the real publish job waits for approval (not dry-run). | ||
| # | ||
| # Usage: Actions → "Publish percent-encoding-iri" → Run workflow (only from `main`). | ||
| # Leave dry_run enabled to run tests + cargo publish --dry-run only. | ||
|
|
||
| name: Publish percent-encoding-iri | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| branches: | ||
| - main | ||
| inputs: | ||
| dry_run: | ||
| description: "If true, only tests + cargo publish --dry-run (no upload)" | ||
| type: boolean | ||
| default: true | ||
|
|
||
| concurrency: | ||
| group: publish-percent-encoding-iri | ||
| cancel-in-progress: false | ||
|
|
||
| env: | ||
| CARGO_NET_GIT_FETCH_WITH_CLI: true | ||
|
|
||
| jobs: | ||
| validate: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: dtolnay/rust-toolchain@stable | ||
|
|
||
| - name: Run tests (default features) | ||
| run: cargo test -p percent-encoding-iri | ||
|
|
||
| - name: Run tests with IRI feature | ||
| run: cargo test -p percent-encoding-iri --features iri | ||
|
|
||
| - name: Package validation (dry-run) | ||
| run: cargo publish -p percent-encoding-iri --dry-run | ||
|
|
||
| publish: | ||
| needs: validate | ||
| if: ${{ !inputs.dry_run }} | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| environment: crates-io | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: dtolnay/rust-toolchain@stable | ||
|
|
||
| - name: Publish to crates.io | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we use Trusted Publishing instead? https://crates.io/docs/trusted-publishing
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we can do it, but we have to set it up on crates.io There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry if I'm forgetting discussion about this, but do we really need to publish to crates.io? Why not something like this?
- name: Cache Cargo registry + git deps
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git # <-- this caches your git dependencies
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since our main goal is to publish Anki, then yes, we will need to publish this fork that is used as a dependency in Anki project. |
||
| run: cargo publish -p percent-encoding-iri | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,29 @@ | ||
| [package] | ||
| name = "percent-encoding" | ||
| name = "percent-encoding-iri" | ||
| version = "2.3.2" | ||
| authors = ["The rust-url developers"] | ||
| description = "Percent encoding and decoding" | ||
| categories = ["no-std"] | ||
| repository = "https://github.com/servo/rust-url/" | ||
| authors = ["The rust-url developers", "Ankitects contributors"] | ||
| description = "Percent encoding with optional IRI-style UTF-8 (enable the `iri` feature). API-compatible with the `percent-encoding` crate name in Rust via `percent_encoding`." | ||
| documentation = "https://docs.rs/percent-encoding-iri" | ||
| repository = "https://github.com/ankitects/rust-url" | ||
| readme = "README.md" | ||
| license = "MIT OR Apache-2.0" | ||
| edition = "2018" | ||
| rust-version = "1.51" | ||
| keywords = ["percent-encoding", "iri", "url", "encoding", "no-std"] | ||
| categories = ["encoding", "no-std", "web-programming"] | ||
| publish = true | ||
| include = ["Cargo.toml", "README.md", "LICENSE-*", "src/**/*"] | ||
|
|
||
| [lib] | ||
| name = "percent_encoding" | ||
|
|
||
| [features] | ||
| default = ["std"] | ||
| std = ["alloc"] | ||
| alloc = [] | ||
| # Encode only ASCII code units in `AsciiSet`; leave UTF-8 non-ASCII bytes literal (IRI-style). | ||
| iri = [] | ||
|
|
||
| [package.metadata.docs.rs] | ||
| all-features = true | ||
| rustdoc-args = ["--generate-link-to-definition"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # percent-encoding-iri | ||
|
|
||
| Same API as [`percent-encoding`](https://crates.io/crates/percent-encoding) from [rust-url](https://github.com/servo/rust-url), published on crates.io under this name so projects can depend on a **distinct package** while optionally enabling **IRI-style** behaviour (UTF-8 non-ASCII octets are not forced to percent-encode when the `iri` feature is on). | ||
|
|
||
| ```toml | ||
| percent-encoding-iri = { version = "2.3.2", features = ["iri"] } | ||
| ``` | ||
|
|
||
| In Rust, import as **`percent_encoding`** (library name), for example: | ||
|
|
||
| ```rust | ||
| use percent_encoding::{utf8_percent_encode, AsciiSet, CONTROLS}; | ||
| ``` | ||
|
|
||
| Without the `iri` feature, encoding matches the stock WHATWG-style rule. | ||
|
|
||
| Source: <https://github.com/ankitects/rust-url> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to confirm with @andrewsanchez if the
releaseenvironment should be used instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, probably it is!
However, it should be released separately from Anki. Because this library needs to exist, be updated in Anki, and then Anki needs to be published.