generated from IWANABETHATGUY/tower-lsp-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 2
215 lines (196 loc) · 6.34 KB
/
nightly.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: nightly
on:
workflow_dispatch:
inputs:
release_name:
type: string
description: Release name, defaults to `nightly`
tag_name:
type: string
description: Tag name, defaults to `nightly-YYYYMMDD`, or release name if specified
prerelease:
type: boolean
default: true
description: "Is this a prerelease?"
schedule:
- cron: "0 4 * * *"
env:
CARGO_TERM_COLOR: always
concurrency:
group: ci-nightly
cancel-in-progress: true
jobs:
check:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.check_changes.outputs.skip }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for changes
id: check_changes
run: |
if [ "$(git log $(git describe --tags --abbrev=0)..HEAD --oneline)" = "" ]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
fi
tag:
needs: check
if: needs.check.outputs.skip != 'true'
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
tag: ${{ steps.output_tag.outputs.tag }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Compute tag
run: echo "TAG=${{ inputs.tag_name || inputs.release_name || 'nightly-$(date +"%Y%m%d")' }}" >> "$GITHUB_ENV"
- name: Create tag
id: create_tag
run: git tag -f ${{ env.TAG }} && git push --tags
- name: Output tag
id: output_tag
run: echo "tag=${{ env.TAG }}" >> "$GITHUB_OUTPUT"
build:
needs: [check, tag]
runs-on: ${{ matrix.runs-on }}
if: needs.check.outputs.skip != 'true'
strategy:
fail-fast: false
matrix:
include:
- runs-on: ubuntu-latest
target: x86_64-unknown-linux-gnu
- runs-on: ubuntu-latest
target: i686-unknown-linux-gnu
- runs-on: ubuntu-latest
target: x86_64-unknown-linux-musl
- runs-on: macos-latest
target: x86_64-apple-darwin
- runs-on: macos-latest
target: aarch64-apple-darwin
- runs-on: windows-latest
target: x86_64-pc-windows-msvc
- runs-on: windows-latest
target: i686-pc-windows-msvc
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-tags: true
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{ matrix.target }}
- name: Additional setup for musl
if: contains(matrix.target, 'musl')
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Additional setup for Linux x86
if: matrix.target == 'i686-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-multilib
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Zip files
shell: bash
run: |
if [ "${{ matrix.runs-on }}" = "windows-latest" ]; then
mv ./target/${{ matrix.target }}/release/odoo-lsp.exe .
7z a -tzip odoo-lsp-${{ matrix.target }}.zip ./odoo-lsp.exe
else
mv ./target/${{ matrix.target }}/release/odoo-lsp .
tar -czvf odoo-lsp-${{ matrix.target }}.tgz odoo-lsp
fi
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: ./odoo-lsp-${{ matrix.target }}.${{ matrix.runs-on == 'windows-latest' && 'zip' || 'tgz' }}
name: odoo-lsp-${{ matrix.target }}.${{ matrix.runs-on == 'windows-latest' && 'zip' || 'tgz' }}
build-extension:
needs: [check, tag]
runs-on: ubuntu-latest
if: needs.check.outputs.skip != 'true'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-tags: true
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node.js
uses: actions/setup-node@v3
with:
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- run: pnpm install
- name: Inject custom release name
if: "${{ inputs.release_name != '' }}"
run: |
cat package.json | jq '. +{"_release":"${{ inputs.release_name }}"}' > __temp__
mv __temp__ package.json
- run: pnpm package
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: ./odoo-lsp-*.vsix
name: odoo-lsp-extension.vsix
untag:
needs: [build, build-extension, tag]
if: always() && (needs.build.result != 'success' || needs.build-extension.result != 'success') && needs.check.outputs.skip != 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-tags: true
- name: Remove tag
run: git tag -d ${{ needs.tag.outputs.tag }} && git push origin :${{ needs.tag.outputs.tag }}
release:
name: Create Release
runs-on: ubuntu-latest
needs: [build, build-extension, tag]
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 5
fetch-tags: true
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Generate checksums
run: |
for file in odoo-lsp-*/odoo-lsp-*; do
openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256";
done
- name: Setup git-cliff
uses: taiki-e/install-action@v2
with:
tool: git-cliff
- name: Generate release notes
run: |
if [[ '${{ needs.tag.outputs.tag }}' == 'nightly-'* ]]; then
./scripts/nightly-changelog > ${{ github.workspace }}-CHANGELOG.txt
else
git cliff -l > ${{ github.workspace }}-CHANGELOG.txt
fi
- name: Release
uses: softprops/action-gh-release@v1
with:
files: odoo-lsp-*/odoo-lsp-*
name: ${{ inputs.release_name || 'nightly' }}
tag_name: ${{ needs.tag.outputs.tag }}
body_path: ${{ github.workspace }}-CHANGELOG.txt
prerelease: ${{ github.event_name != 'workflow_dispatch' || inputs.prerelease }}