This repository has been archived by the owner on Mar 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
183 lines (161 loc) · 6.5 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: CI
on: [push, pull_request]
jobs:
test:
name: Python ${{ matrix.python-version }} compile test
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '2.7', '3.x' ]
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install dependencies
run: pip install yapf
- name: Check compiles
run: python -m py_compile main.py
build:
name: ${{ matrix.config.kind }} ${{ matrix.config.os }}
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
config:
- os: macOS-latest
kind: test_release
- os: windows-latest
kind: test_release
- os: ubuntu-latest
kind: test_release
outputs:
LINUX_ZIP_CHECKSUM: ${{steps.linux_pre_release.outputs.ZIP_CHECKSUM}}
MAC_ZIP_CHECKSUM: ${{steps.mac_pre_release.outputs.ZIP_CHECKSUM}}
WINDOWS_ZIP_CHECKSUM: ${{steps.windows_pre_release.outputs.ZIP_CHECKSUM}}
steps:
- name: Checkout
uses: actions/checkout@v2
# CACHE SETUP
- name: Cache cargo
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ matrix.config.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# BUILD
- name: Build release
if: matrix.config.kind == 'test_release'
run: |
cd executable
cargo build --release --locked --all-targets --verbose
cp ../main.py target/release/main.py
# Release
- name: Pre-release (Linux)
id: linux_pre_release
if: startsWith(matrix.config.os, 'ubuntu') && matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/')
run: |
cd executable/target/release
zip -r dprint-plugin-yapf-x86_64-unknown-linux-gnu.zip dprint-plugin-yapf main.py
echo "::set-output name=ZIP_CHECKSUM::$(shasum -a 256 dprint-plugin-yapf-x86_64-unknown-linux-gnu.zip | awk '{print $1}')"
- name: Pre-release (Mac)
id: mac_pre_release
if: startsWith(matrix.config.os, 'macOS') && matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/')
run: |
cd executable/target/release
zip -r dprint-plugin-yapf-x86_64-apple-darwin.zip dprint-plugin-yapf main.py
echo "::set-output name=ZIP_CHECKSUM::$(shasum -a 256 dprint-plugin-yapf-x86_64-apple-darwin.zip | awk '{print $1}')"
- name: Pre-release (Windows)
id: windows_pre_release
if: startsWith(matrix.config.os, 'windows') && matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/')
run: |
cd executable/target/release
Compress-Archive -CompressionLevel Optimal -Force -Path dprint-plugin-yapf.exe, main.py -DestinationPath dprint-plugin-yapf-x86_64-pc-windows-msvc.zip
echo "::set-output name=ZIP_CHECKSUM::$(shasum -a 256 dprint-plugin-yapf-x86_64-pc-windows-msvc.zip | awk '{print $1}')"
# UPLOAD ARTIFACTS
- name: Upload Artifacts (Linux)
uses: actions/upload-artifact@v2
if: startsWith(matrix.config.os, 'ubuntu') && matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/')
with:
name: linux-artifacts
path: executable/target/release/dprint-plugin-yapf-x86_64-unknown-linux-gnu.zip
- name: Upload Artifacts (Mac)
uses: actions/upload-artifact@v2
if: startsWith(matrix.config.os, 'macOS') && matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/')
with:
name: mac-artifacts
path: executable/target/release/dprint-plugin-yapf-x86_64-apple-darwin.zip
- name: Upload Artifacts (Windows)
uses: actions/upload-artifact@v2
if: startsWith(matrix.config.os, 'windows') && matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/')
with:
name: windows-artifacts
path: executable/target/release/dprint-plugin-yapf-x86_64-pc-windows-msvc.zip
draft_release:
name: draft_release
if: startsWith(github.ref, 'refs/tags/')
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v2
- name: Move downloaded artifacts
run: |
mv linux-artifacts/dprint-plugin-yapf-x86_64-unknown-linux-gnu.zip .
mv mac-artifacts/dprint-plugin-yapf-x86_64-apple-darwin.zip .
mv windows-artifacts/dprint-plugin-yapf-x86_64-pc-windows-msvc.zip .
- name: Output checksums
run: |
echo "Linux zip: ${{needs.build.outputs.LINUX_ZIP_CHECKSUM}}"
echo "Mac zip: ${{needs.build.outputs.MAC_ZIP_CHECKSUM}}"
echo "Windows zip: ${{needs.build.outputs.WINDOWS_ZIP_CHECKSUM}}"
- name: Create plugin file
run: node scripts/createPluginFile.js
- name: Get tag version
id: get_tag_version
run: echo ::set-output name=TAG_VERSION::${GITHUB_REF/refs\/tags\//}
- name: Get plugin file checksum
id: get_plugin_file_checksum
run: echo "::set-output name=CHECKSUM::$(shasum -a 256 plugin.exe-plugin | awk '{print $1}')"
- name: Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
dprint-plugin-yapf-x86_64-apple-darwin.zip
dprint-plugin-yapf-x86_64-unknown-linux-gnu.zip
dprint-plugin-yapf-x86_64-pc-windows-msvc.zip
plugin.exe-plugin
body: |
## Install
Dependencies:
1. Install python and ensure it's on the path.
2. Install dprint's CLI >= 0.9.0
In dprint configuration file:
1. Specify the plugin url and checksum in the `"plugins"` array:
```jsonc
{
// etc...
"plugins": [
"https://plugins.dprint.dev/yapf-${{ steps.get_tag_version.outputs.TAG_VERSION }}.exe-plugin@${{ steps.get_plugin_file_checksum.outputs.CHECKSUM }}"
]
}
```
2. Ensure the `py` extension is matched in an `"includes"` pattern.
3. Add a `"yapf"` configuration property if desired.
```jsonc
{
// ...etc...
"yapf": {
"based_on_style": "pep8",
"spaces_before_comment": 4
}
}
```
draft: false