|
1 | | -name: CI |
2 | | - |
3 | | -on: [push, pull_request] |
4 | | - |
5 | | -jobs: |
6 | | - build: |
7 | | - name: ${{ matrix.config.kind }} ${{ matrix.config.os }} |
8 | | - runs-on: ${{ matrix.config.os }} |
9 | | - strategy: |
10 | | - matrix: |
11 | | - config: |
12 | | - - os: ubuntu-latest |
13 | | - kind: test_release |
14 | | - - os: ubuntu-latest |
15 | | - kind: test_debug |
16 | | - |
17 | | - env: |
18 | | - CARGO_INCREMENTAL: 0 |
19 | | - RUST_BACKTRACE: full |
20 | | - |
21 | | - steps: |
22 | | - - uses: actions/checkout@v3 |
23 | | - - uses: dsherret/rust-toolchain-file@v1 |
24 | | - - name: Install wasm32 target |
25 | | - if: matrix.config.kind == 'test_release' |
26 | | - run: rustup target add wasm32-unknown-unknown |
27 | | - |
28 | | - - uses: Swatinem/rust-cache@v2 |
29 | | - with: |
30 | | - save-if: ${{ github.ref == 'refs/heads/main' }} |
31 | | - |
32 | | - - name: Build debug |
33 | | - if: matrix.config.kind == 'test_debug' |
34 | | - run: cargo build --verbose |
35 | | - - name: Build release |
36 | | - if: matrix.config.kind == 'test_release' |
37 | | - run: cargo build --target wasm32-unknown-unknown --features wasm --release --verbose |
38 | | - |
39 | | - - name: Test debug |
40 | | - if: matrix.config.kind == 'test_debug' |
41 | | - run: cargo test --verbose |
42 | | - - name: Test release |
43 | | - if: matrix.config.kind == 'test_release' |
44 | | - run: cargo test --release --verbose |
45 | | - |
46 | | - - name: Get tag version |
47 | | - if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
48 | | - id: get_tag_version |
49 | | - run: echo ::set-output name=TAG_VERSION::${GITHUB_REF/refs\/tags\//} |
50 | | - |
51 | | - # NPM |
52 | | - - uses: actions/setup-node@v2 |
53 | | - if: matrix.config.kind == 'test_release' |
54 | | - with: |
55 | | - node-version: '18.x' |
56 | | - registry-url: 'https://registry.npmjs.org' |
57 | | - |
58 | | - - name: Setup and test npm deployment |
59 | | - if: matrix.config.kind == 'test_release' |
60 | | - run: | |
61 | | - cd deployment/npm |
62 | | - npm install |
63 | | - node setup.js ${{ steps.get_tag_version.outputs.TAG_VERSION }} |
64 | | - npm run test |
65 | | -
|
66 | | - - name: npm publish |
67 | | - if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
68 | | - env: |
69 | | - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
70 | | - run: | |
71 | | - cd deployment/npm |
72 | | - npm publish --access public |
73 | | - git reset --hard |
74 | | -
|
75 | | - # CARGO PUBLISH |
76 | | - - name: Cargo login |
77 | | - if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
78 | | - run: cargo login ${{ secrets.CRATES_TOKEN }} |
79 | | - |
80 | | - - name: Cargo publish |
81 | | - if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
82 | | - run: cargo publish |
83 | | - |
84 | | - # GITHUB RELEASE |
85 | | - - name: Pre-release |
86 | | - if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
87 | | - run: | |
88 | | - # update config schema to have version |
89 | | - sed -i 's/sql\/0.0.0/sql\/${{ steps.get_tag_version.outputs.TAG_VERSION }}/' deployment/schema.json |
90 | | - # rename the wasm file |
91 | | - (cd target/wasm32-unknown-unknown/release/ && mv dprint_plugin_sql.wasm plugin.wasm) |
92 | | - - name: Release |
93 | | - uses: softprops/action-gh-release@v1 |
94 | | - if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
95 | | - env: |
96 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
97 | | - with: |
98 | | - files: | |
99 | | - target/wasm32-unknown-unknown/release/plugin.wasm |
100 | | - deployment/schema.json |
101 | | - body: | |
102 | | - ## Install |
103 | | -
|
104 | | - [Install](https://dprint.dev/install/) and [setup](https://dprint.dev/setup/) dprint. |
105 | | -
|
106 | | - Then in your project's dprint configuration file: |
107 | | -
|
108 | | - 1. Specify the plugin url in the `"plugins"` array. |
109 | | - 2. Add a `"sql"` configuration property if desired. |
110 | | - ```jsonc |
111 | | - { |
112 | | - // ...etc... |
113 | | - "sql": { |
114 | | - // sql config goes here |
115 | | - }, |
116 | | - "plugins": [ |
117 | | - "https://plugins.dprint.dev/sql-${{ steps.get_tag_version.outputs.TAG_VERSION }}.wasm" |
118 | | - ] |
119 | | - } |
120 | | - ``` |
121 | | -
|
122 | | - ## JS Formatting API |
123 | | -
|
124 | | - * [JS Formatter](https://github.com/dprint/js-formatter) - Browser/Deno and Node |
125 | | - * [npm package](https://www.npmjs.com/package/@dprint/sql) |
126 | | - draft: false |
| 1 | +name: CI |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + name: ${{ matrix.config.kind }} ${{ matrix.config.os }} |
| 8 | + runs-on: ${{ matrix.config.os }} |
| 9 | + strategy: |
| 10 | + matrix: |
| 11 | + config: |
| 12 | + - os: ubuntu-latest |
| 13 | + kind: test_release |
| 14 | + - os: ubuntu-latest |
| 15 | + kind: test_debug |
| 16 | + |
| 17 | + env: |
| 18 | + CARGO_INCREMENTAL: 0 |
| 19 | + RUST_BACKTRACE: full |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v6 |
| 23 | + - uses: dsherret/rust-toolchain-file@v1 |
| 24 | + - name: Install wasm32 target |
| 25 | + if: matrix.config.kind == 'test_release' |
| 26 | + run: rustup target add wasm32-unknown-unknown |
| 27 | + |
| 28 | + - uses: Swatinem/rust-cache@v2 |
| 29 | + with: |
| 30 | + save-if: ${{ github.ref == 'refs/heads/main' }} |
| 31 | + |
| 32 | + - name: Build debug |
| 33 | + if: matrix.config.kind == 'test_debug' |
| 34 | + run: cargo build |
| 35 | + - name: Build release |
| 36 | + if: matrix.config.kind == 'test_release' |
| 37 | + run: cargo build --target wasm32-unknown-unknown --features wasm --release |
| 38 | + |
| 39 | + - name: Test debug |
| 40 | + if: matrix.config.kind == 'test_debug' |
| 41 | + run: cargo test |
| 42 | + - name: Test release |
| 43 | + if: matrix.config.kind == 'test_release' |
| 44 | + run: cargo test --release |
| 45 | + |
| 46 | + - name: Get tag version |
| 47 | + if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
| 48 | + id: get_tag_version |
| 49 | + run: echo "TAG_VERSION=${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_OUTPUT" |
| 50 | + |
| 51 | + # NPM |
| 52 | + - uses: actions/setup-node@v6 |
| 53 | + if: matrix.config.kind == 'test_release' |
| 54 | + with: |
| 55 | + node-version: '24.x' |
| 56 | + registry-url: 'https://registry.npmjs.org' |
| 57 | + |
| 58 | + - name: Setup and test npm deployment |
| 59 | + if: matrix.config.kind == 'test_release' |
| 60 | + run: | |
| 61 | + cd deployment/npm |
| 62 | + npm install |
| 63 | + node setup.js |
| 64 | + npm run test |
| 65 | +
|
| 66 | + # GITHUB RELEASE |
| 67 | + - uses: denoland/setup-deno@v2 |
| 68 | + if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
| 69 | + with: |
| 70 | + deno-version: v2.x |
| 71 | + - name: Pre-release |
| 72 | + if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
| 73 | + run: | |
| 74 | + # update config schema to have version |
| 75 | + sed -i 's/sql\/0.0.0/sql\/${{ steps.get_tag_version.outputs.TAG_VERSION }}/' deployment/schema.json |
| 76 | + # rename the wasm file |
| 77 | + (cd target/wasm32-unknown-unknown/release/ && mv dprint_plugin_sql.wasm plugin.wasm) |
| 78 | + # create release notes |
| 79 | + deno run -A ./scripts/generateReleaseNotes.ts ${{ steps.get_tag_version.outputs.TAG_VERSION }} > ${{ github.workspace }}-CHANGELOG.txt |
| 80 | + - name: Release |
| 81 | + uses: softprops/action-gh-release@v2 |
| 82 | + if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
| 83 | + env: |
| 84 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 85 | + with: |
| 86 | + files: | |
| 87 | + target/wasm32-unknown-unknown/release/plugin.wasm |
| 88 | + deployment/schema.json |
| 89 | + body_path: ${{ github.workspace }}-CHANGELOG.txt |
| 90 | + draft: false |
0 commit comments