From 283743fa518f3fc0fe7fac81e0ccac625a674d5b Mon Sep 17 00:00:00 2001 From: Salomon Popp Date: Wed, 2 Feb 2022 00:12:19 +0100 Subject: [PATCH] release(ci): publish (#1) --- .github/workflows/ci.yml | 84 ++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 2 +- LICENSE | 23 +++++++++++ deployment/schema.json | 50 ++++++++++++++++++++++++ src/wasm_plugin.rs | 10 ++++- 5 files changed, 166 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 LICENSE create mode 100644 deployment/schema.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8457ed7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,84 @@ +name: CI +# taken from main dprint plugins +# without npm for now + +on: [push, pull_request] + +jobs: + build: + name: ${{ matrix.config.kind }} ${{ matrix.config.os }} + runs-on: ${{ matrix.config.os }} + strategy: + matrix: + config: + - os: ubuntu-latest + kind: test_release + - os: ubuntu-latest + kind: test_debug + + env: + CARGO_INCREMENTAL: 0 + RUST_BACKTRACE: full + + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: 1.57.0 + override: true + - name: Install wasm32 target + if: matrix.config.kind == 'test_release' + run: rustup target add wasm32-unknown-unknown + + - name: Cache cargo + if: startsWith(github.ref, 'refs/tags/') != true + uses: Swatinem/rust-cache@v1 + + - name: Build debug + if: matrix.config.kind == 'test_debug' + run: cargo build --verbose + - name: Build release + if: matrix.config.kind == 'test_release' + run: cargo build --target wasm32-unknown-unknown --features wasm --release --verbose + + - name: Test debug + if: matrix.config.kind == 'test_debug' + run: cargo test --verbose + - name: Test release + if: matrix.config.kind == 'test_release' + run: cargo test --release --verbose + + - name: Get tag version + if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') + id: get_tag_version + run: echo ::set-output name=TAG_VERSION::${GITHUB_REF/refs\/tags\//} + + # CARGO PUBLISH + - name: Cargo login + if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') + run: cargo login ${{ secrets.CRATES_TOKEN }} + + - name: Cargo publish + if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') + run: cargo publish + + # GITHUB RELEASE + - name: Pre-release + if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') + run: | + # update config schema to have version + sed -i 's/0.0.0/${{ steps.get_tag_version.outputs.TAG_VERSION }}/' deployment/schema.json + # rename the wasm file + (cd target/wasm32-unknown-unknown/release/ && mv dprint_plugin_css.wasm plugin.wasm) + - name: Release + uses: softprops/action-gh-release@v1 + if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: | + target/wasm32-unknown-unknown/release/plugin.wasm + deployment/schema.json + body: "" + draft: false diff --git a/Cargo.toml b/Cargo.toml index adaf07c..a2821ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ wasm = ["serde_json", "dprint-core/wasm"] [dependencies] anyhow = "1.0.51" parcel_css = { version = "1.0.0-alpha.14" } -dprint-core = { version = "0.49.0", features = ["formatting"] } +dprint-core = { version = "0.50.0", features = ["formatting"] } serde = { version = "1.0.117", features = ["derive"] } serde_json = { version = "1.0", optional = true } diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..10627c6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) 2021-2022 Salomon Popp + +Copyright (c) 2021-2022 David Sherret + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/deployment/schema.json b/deployment/schema.json new file mode 100644 index 0000000..07e29eb --- /dev/null +++ b/deployment/schema.json @@ -0,0 +1,50 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://plugins.dprint.dev/disrupted/dprint-plugin-css/0.0.0/schema.json", + "type": "object", + "definitions": { + "useTabs": { + "description": "Whether to use tabs (true) or spaces (false).", + "type": "boolean", + "default": false, + "oneOf": [{ + "const": true, + "description": "" + }, { + "const": false, + "description": "" + }] + }, + "newLineKind": { + "description": "The kind of newline to use.", + "type": "string", + "default": "lf", + "oneOf": [{ + "const": "auto", + "description": "For each file, uses the newline kind found at the end of the last line." + }, { + "const": "crlf", + "description": "Uses carriage return, line feed." + }, { + "const": "lf", + "description": "Uses line feed." + }, { + "const": "system", + "description": "Uses the system standard (ex. crlf on Windows)." + }] + } + }, + "properties": { + "indentWidth": { + "description": "The number of characters for an indent.", + "default": 2, + "type": "number" + }, + "useTabs": { + "$ref": "#/definitions/useTabs" + }, + "newLineKind": { + "$ref": "#/definitions/newLineKind" + } + } +} diff --git a/src/wasm_plugin.rs b/src/wasm_plugin.rs index 8422b20..d8956d6 100644 --- a/src/wasm_plugin.rs +++ b/src/wasm_plugin.rs @@ -31,8 +31,14 @@ impl PluginHandler for CssPluginHandler { config_key: "css".to_string(), file_extensions: vec!["css".to_string()], file_names: vec![], - help_url: "https://dprint.dev/plugins/css".to_string(), - config_schema_url: "".to_string(), + help_url: "https://github.com/disrupted/dprint-plugin-css/issues".to_string(), + config_schema_url: format!( + "https://plugins.dprint.dev/disrupted/dprint-plugin-css/{}/schema.json", + version + ), + update_url: Some( + "https://plugins.dprint.dev/disrupted/dprint-plugin-css/latest.json".to_string(), + ), } }