|
1 | 1 | name: CI
|
2 | 2 |
|
3 |
| -on: [push, pull_request] |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + tags: |
| 9 | + - '*' |
4 | 10 |
|
5 | 11 | jobs:
|
6 | 12 | build:
|
7 |
| - name: test_release |
8 |
| - runs-on: ubuntu-latest |
| 13 | + name: ${{ matrix.config.kind }} ${{ matrix.config.os }} |
| 14 | + runs-on: ${{ matrix.config.os }} |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + config: |
| 18 | + # uses an older version of ubuntu because of issue dprint/#483 |
| 19 | + - os: ubuntu-18.04 |
| 20 | + kind: test_release |
| 21 | + - os: macOS-latest |
| 22 | + kind: test_release |
| 23 | + - os: windows-2019 |
| 24 | + kind: test_release |
| 25 | + |
| 26 | + outputs: |
| 27 | + LINUX_ZIP_CHECKSUM: ${{steps.linux_pre_release.outputs.ZIP_CHECKSUM}} |
| 28 | + MAC_ZIP_CHECKSUM: ${{steps.mac_pre_release.outputs.ZIP_CHECKSUM}} |
| 29 | + WINDOWS_ZIP_CHECKSUM: ${{steps.windows_pre_release.outputs.ZIP_CHECKSUM}} |
| 30 | + |
| 31 | + env: |
| 32 | + CARGO_INCREMENTAL: 0 |
| 33 | + RUST_BACKTRACE: full |
| 34 | + CFG_RELEASE_CHANNEL: nightly |
9 | 35 |
|
| 36 | + steps: |
| 37 | + # Setup |
| 38 | + - uses: actions/checkout@v2 |
| 39 | + - uses: dtolnay/rust-toolchain@stable |
| 40 | + - uses: Swatinem/rust-cache@v1 |
| 41 | + |
| 42 | + # Build |
| 43 | + - name: Build release |
| 44 | + if: matrix.config.kind == 'test_release' |
| 45 | + run: cargo build --release |
| 46 | + |
| 47 | + - name: Test release |
| 48 | + if: matrix.config.kind == 'test_release' |
| 49 | + run: cargo test --release |
| 50 | + |
| 51 | + # Release |
| 52 | + - name: Pre-release (Linux) |
| 53 | + id: linux_pre_release |
| 54 | + if: startsWith(matrix.config.os, 'ubuntu') && matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
| 55 | + run: | |
| 56 | + cd target/release |
| 57 | + zip -r dprint-plugin-prettier-x86_64-unknown-linux-gnu.zip dprint-plugin-prettier dprint-plugin-prettier |
| 58 | + echo "::set-output name=ZIP_CHECKSUM::$(shasum -a 256 dprint-plugin-prettier-x86_64-unknown-linux-gnu.zip | awk '{print $1}')" |
| 59 | + - name: Pre-release (Mac) |
| 60 | + id: mac_pre_release |
| 61 | + if: startsWith(matrix.config.os, 'macOS') && matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
| 62 | + run: | |
| 63 | + cd target/release |
| 64 | + zip -r dprint-plugin-prettier-x86_64-apple-darwin.zip dprint-plugin-prettier dprint-plugin-prettier |
| 65 | + echo "::set-output name=ZIP_CHECKSUM::$(shasum -a 256 dprint-plugin-prettier-x86_64-apple-darwin.zip | awk '{print $1}')" |
| 66 | + - name: Pre-release (Windows) |
| 67 | + id: windows_pre_release |
| 68 | + if: startsWith(matrix.config.os, 'windows') && matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
| 69 | + run: | |
| 70 | + cd target/release |
| 71 | + Compress-Archive -CompressionLevel Optimal -Force -Path dprint-plugin-prettier.exe -DestinationPath dprint-plugin-prettier-x86_64-pc-windows-msvc.zip |
| 72 | + echo "::set-output name=ZIP_CHECKSUM::$(shasum -a 256 dprint-plugin-prettier-x86_64-pc-windows-msvc.zip | awk '{print $1}')" |
| 73 | +
|
| 74 | + # Upload Artifacts |
| 75 | + - name: Upload Artifacts (Linux) |
| 76 | + uses: actions/upload-artifact@v2 |
| 77 | + if: startsWith(matrix.config.os, 'ubuntu') && matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
| 78 | + with: |
| 79 | + name: linux-artifacts |
| 80 | + path: target/release/dprint-plugin-prettier-x86_64-unknown-linux-gnu.zip |
| 81 | + - name: Upload Artifacts (Mac) |
| 82 | + uses: actions/upload-artifact@v2 |
| 83 | + if: startsWith(matrix.config.os, 'macOS') && matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
| 84 | + with: |
| 85 | + name: mac-artifacts |
| 86 | + path: target/release/dprint-plugin-prettier-x86_64-apple-darwin.zip |
| 87 | + - name: Upload Artifacts (Windows) |
| 88 | + uses: actions/upload-artifact@v2 |
| 89 | + if: startsWith(matrix.config.os, 'windows') && matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/') |
| 90 | + with: |
| 91 | + name: windows-artifacts |
| 92 | + path: target/release/dprint-plugin-prettier-x86_64-pc-windows-msvc.zip |
| 93 | + |
| 94 | + |
| 95 | + draft_release: |
| 96 | + name: draft_release |
| 97 | + if: startsWith(github.ref, 'refs/tags/') |
| 98 | + needs: build |
| 99 | + runs-on: ubuntu-latest |
10 | 100 | steps:
|
11 | 101 | - name: Checkout
|
12 | 102 | uses: actions/checkout@v2
|
13 |
| - - name: Cache node_modules |
14 |
| - uses: actions/cache@v2 |
15 |
| - with: |
16 |
| - path: | |
17 |
| - **/node_modules |
18 |
| - key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} |
| 103 | + - uses: denoland/setup-deno@v1 |
| 104 | + - name: Download artifacts |
| 105 | + uses: actions/download-artifact@v2 |
19 | 106 |
|
20 |
| - - name: NPM install |
21 |
| - run: npm ci |
22 |
| - - name: Build |
23 |
| - run: npm run build |
| 107 | + - name: Move downloaded artifacts |
| 108 | + run: | |
| 109 | + mv linux-artifacts/dprint-plugin-prettier-x86_64-unknown-linux-gnu.zip . |
| 110 | + mv mac-artifacts/dprint-plugin-prettier-x86_64-apple-darwin.zip . |
| 111 | + mv windows-artifacts/dprint-plugin-prettier-x86_64-pc-windows-msvc.zip . |
24 | 112 |
|
25 |
| - - name: Package |
| 113 | + - name: Output checksums |
26 | 114 | run: |
|
27 |
| - mv index-macos dprint-plugin-prettier |
28 |
| - zip -r dprint-plugin-prettier-x86_64-apple-darwin.zip dprint-plugin-prettier |
29 |
| - rm dprint-plugin-prettier |
30 |
| - mv index-linux dprint-plugin-prettier |
31 |
| - zip -r dprint-plugin-prettier-x86_64-unknown-linux-gnu.zip dprint-plugin-prettier |
32 |
| - mv index-win.exe dprint-plugin-prettier.exe |
33 |
| - zip -r dprint-plugin-prettier-x86_64-pc-windows-msvc.zip dprint-plugin-prettier.exe |
| 115 | + echo "Linux zip: ${{needs.build.outputs.LINUX_ZIP_CHECKSUM}}" |
| 116 | + echo "Mac zip: ${{needs.build.outputs.MAC_ZIP_CHECKSUM}}" |
| 117 | + echo "Windows zip: ${{needs.build.outputs.WINDOWS_ZIP_CHECKSUM}}" |
34 | 118 |
|
35 | 119 | - name: Create plugin file
|
36 |
| - run: node scripts/createPluginFile.js |
| 120 | + run: deno run --allow-read=. --allow-write=. scripts/create_plugin_file.ts |
37 | 121 |
|
38 | 122 | - name: Get tag version
|
39 |
| - if: startsWith(github.ref, 'refs/tags/') |
40 | 123 | id: get_tag_version
|
41 | 124 | run: echo ::set-output name=TAG_VERSION::${GITHUB_REF/refs\/tags\//}
|
42 | 125 |
|
43 | 126 | - name: Get plugin file checksum
|
44 |
| - if: startsWith(github.ref, 'refs/tags/') |
45 | 127 | id: get_plugin_file_checksum
|
46 | 128 | run: echo "::set-output name=CHECKSUM::$(shasum -a 256 plugin.exe-plugin | awk '{print $1}')"
|
47 | 129 |
|
48 | 130 | - name: Release
|
49 | 131 | uses: softprops/action-gh-release@v1
|
50 |
| - if: startsWith(github.ref, 'refs/tags/') |
51 | 132 | env:
|
52 | 133 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
53 | 134 | with:
|
|
67 | 148 | {
|
68 | 149 | // etc...
|
69 | 150 | "plugins": [
|
| 151 | + // ...add other dprint plugins here that you want to take precedence over prettier... |
70 | 152 | "https://plugins.dprint.dev/prettier-${{ steps.get_tag_version.outputs.TAG_VERSION }}.exe-plugin@${{ steps.get_plugin_file_checksum.outputs.CHECKSUM }}"
|
71 | 153 | ]
|
72 | 154 | }
|
|
0 commit comments