Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
release(ci): publish (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
disrupted authored Feb 1, 2022
1 parent 0fa8d49 commit 283743f
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 3 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
23 changes: 23 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
50 changes: 50 additions & 0 deletions deployment/schema.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
10 changes: 8 additions & 2 deletions src/wasm_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ impl PluginHandler<Configuration> 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(),
),
}
}

Expand Down

0 comments on commit 283743f

Please sign in to comment.