-
Notifications
You must be signed in to change notification settings - Fork 133
156 lines (138 loc) · 4.76 KB
/
release.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
name: Release
on:
push:
tags:
- '*.*.*'
# These are used to trigger (only) MELPA Stable. See
# https://github.com/emacs-tree-sitter/elisp-tree-sitter/issues/177
- '!melpa-stable/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
# TODO: Get host platform from somewher instead of specifying it explicitly here.
- os: macos-12
bundle_os: macos
emacs-version: '27.2'
ext: dylib
host: x86_64-apple-darwin
- os: macos-12
bundle_os: macos
emacs-version: '27.2'
ext: dylib
target: aarch64-apple-darwin
- os: ubuntu-20.04
bundle_os: linux
emacs-version: '27.2'
ext: so
host: x86_64-unknown-linux-gnu
- os: windows-2019
bundle_os: windows
emacs-version: '27.2'
ext: dll
host: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- run: .github/script/setup
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install tree-sitter CLI
run: npm install -g [email protected]
- uses: jcs090218/setup-emacs@master
with:
version: ${{ matrix.emacs-version }}
- uses: emacs-eask/setup-eask@master
with:
version: 'snapshot'
- run: eask install-deps
- run: script/compile all -target "${{ matrix.target }}"
continue-on-error: ${{ !matrix.target }}
- run: script/inspect-binaries
continue-on-error: true
- run: script/test
if: ${{ !matrix.target }}
continue-on-error: ${{ runner.os == 'Windows' }}
- run: eask package
if: ${{ !matrix.target }}
- name: Determine version
if: runner.os != 'Windows'
run: |
bundle_version=$(script/bundle-version)
bundle_version=${bundle_version//$'\n'/}
echo BUNDLE_VERSION=$bundle_version >> $GITHUB_ENV
- name: Determine version
if: runner.os == 'Windows'
run: |
$bundle_version = ((script/bundle-version) | Out-String).Trim()
echo BUNDLE_VERSION=$bundle_version | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Rename cross-compilation's binary
if: matrix.target
run: |
mv tree-sitter-grammars-${{ matrix.bundle_os }}-${{ env.BUNDLE_VERSION }}.tar.gz tree-sitter-grammars.${{ matrix.target }}.v${{ env.BUNDLE_VERSION }}.tar.gz
- name: Make a target-explicit copy of native compilation's binary
if: ${{ !matrix.target && matrix.host }}
shell: bash
run: |
cp tree-sitter-grammars-${{ matrix.bundle_os }}-${{ env.BUNDLE_VERSION }}.tar.gz tree-sitter-grammars.${{ matrix.host }}.v${{ env.BUNDLE_VERSION }}.tar.gz
- name: Upload binary
uses: actions/upload-artifact@v2
with:
name: tree-sitter-grammars
path: tree-sitter-grammars*.tar.gz
if-no-files-found: error
publish:
needs: build
runs-on: ubuntu-20.04
steps:
- uses: jcs090218/setup-emacs@master
with:
version: '27.2'
- uses: actions/checkout@v4
- name: Generate release notes
run: |
RELEASE_VERSION=$(git describe --tags --abbrev=0)
script/dev release-notes "$RELEASE_VERSION" > RELEASE-NOTES
echo RELEASE_VERSION=$RELEASE_VERSION >> $GITHUB_ENV
cat RELEASE-NOTES
- name: Download binaries
uses: actions/download-artifact@v2
with:
name: tree-sitter-grammars
- run: ls -R
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
body_path: RELEASE-NOTES
files: |
tree-sitter-grammars*.tar.gz
- name: Greenlight releasing to MELPA
uses: actions/github-script@v5
with:
github-token: ${{ secrets.PAT }}
script: |
github.rest.git.updateRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "heads/release",
sha: context.sha
})
continue-on-error: true
- name: Greenlight releasing to MELPA Stable
uses: actions/github-script@v5
with:
github-token: ${{ secrets.PAT }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/melpa-stable/v${{ env.RELEASE_VERSION }}",
sha: context.sha
})
continue-on-error: true