Skip to content

Commit 199a89a

Browse files
committed
chore: add release build workflow
1 parent b8f6b76 commit 199a89a

File tree

4 files changed

+223
-24
lines changed

4 files changed

+223
-24
lines changed

.github/.gitkeep

Whitespace-only changes.

.github/dependabot.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
name: Release
2+
on:
3+
# schedule:
4+
# - cron: '0 0 * * *' # midnight UTC
5+
6+
push:
7+
tags:
8+
- 'v[0-9]+.[0-9]+.[0-9]+'
9+
## - release
10+
11+
env:
12+
BIN_NAME: simple-completion-language-server
13+
PROJECT_NAME: scls
14+
REPO_NAME: d1y/scls
15+
BREW_TAP: d1ylab/homebrew-tap
16+
17+
jobs:
18+
dist:
19+
name: Dist
20+
runs-on: ${{ matrix.os }}
21+
strategy:
22+
fail-fast: false # don't fail other jobs if one fails
23+
matrix:
24+
build: [x86_64-linux, aarch64-linux, x86_64-macos, x86_64-windows] #, x86_64-win-gnu, win32-msvc
25+
include:
26+
- build: x86_64-linux
27+
os: ubuntu-20.04
28+
rust: stable
29+
target: x86_64-unknown-linux-gnu
30+
cross: false
31+
- build: aarch64-linux
32+
os: ubuntu-20.04
33+
rust: stable
34+
target: aarch64-unknown-linux-gnu
35+
cross: true
36+
- build: x86_64-macos
37+
os: macos-latest
38+
rust: stable
39+
target: x86_64-apple-darwin
40+
cross: false
41+
- build: x86_64-windows
42+
os: windows-2019
43+
rust: stable
44+
target: x86_64-pc-windows-msvc
45+
cross: false
46+
- build: aarch64-macos
47+
os: macos-latest
48+
rust: stable
49+
target: aarch64-apple-darwin
50+
# - build: x86_64-win-gnu
51+
# os: windows-2019
52+
# rust: stable-x86_64-gnu
53+
# target: x86_64-pc-windows-gnu
54+
# - build: win32-msvc
55+
# os: windows-2019
56+
# rust: stable
57+
# target: i686-pc-windows-msvc
58+
59+
steps:
60+
- name: Checkout sources
61+
uses: actions/checkout@v2
62+
with:
63+
submodules: true
64+
65+
- name: Install ${{ matrix.rust }} toolchain
66+
uses: actions-rs/toolchain@v1
67+
with:
68+
profile: minimal
69+
toolchain: ${{ matrix.rust }}
70+
target: ${{ matrix.target }}
71+
override: true
72+
73+
# 测试个集贸
74+
# - name: Run cargo test
75+
# uses: actions-rs/cargo@v1
76+
# with:
77+
# use-cross: ${{ matrix.cross }}
78+
# command: test
79+
# args: --release --locked --target ${{ matrix.target }}
80+
81+
- name: Build release binary
82+
uses: actions-rs/cargo@v1
83+
with:
84+
use-cross: ${{ matrix.cross }}
85+
command: build
86+
args: --release --locked --target ${{ matrix.target }}
87+
88+
- name: Strip release binary (linux and macos)
89+
if: matrix.build == 'x86_64-linux' || matrix.build == 'x86_64-macos'
90+
run: strip "target/${{ matrix.target }}/release/$BIN_NAME"
91+
92+
- name: Strip release binary (arm)
93+
if: matrix.build == 'aarch64-linux'
94+
run: |
95+
docker run --rm -v \
96+
"$PWD/target:/target:Z" \
97+
rustembedded/cross:${{ matrix.target }} \
98+
aarch64-linux-gnu-strip \
99+
/target/${{ matrix.target }}/release/$BIN_NAME
100+
101+
- name: Build archive
102+
shell: bash
103+
run: |
104+
mkdir dist
105+
if [ "${{ matrix.os }}" = "windows-2019" ]; then
106+
cp "target/${{ matrix.target }}/release/$BIN_NAME.exe" "dist/"
107+
else
108+
cp "target/${{ matrix.target }}/release/$BIN_NAME" "dist/"
109+
fi
110+
111+
- uses: actions/upload-artifact@v2.2.4
112+
with:
113+
name: bins-${{ matrix.build }}
114+
path: dist
115+
116+
publish:
117+
name: Publish
118+
needs: [dist]
119+
runs-on: ubuntu-latest
120+
steps:
121+
- name: Checkout sources
122+
uses: actions/checkout@v2
123+
with:
124+
submodules: false
125+
126+
- uses: actions/download-artifact@v2
127+
# with:
128+
# path: dist
129+
# - run: ls -al ./dist
130+
- run: ls -al bins-*
131+
132+
- name: Calculate tag name
133+
run: |
134+
name=dev
135+
if [[ $GITHUB_REF == refs/tags/v* ]]; then
136+
name=${GITHUB_REF:10}
137+
fi
138+
echo ::set-output name=val::$name
139+
echo TAG=$name >> $GITHUB_ENV
140+
id: tagname
141+
142+
- name: Build archive
143+
shell: bash
144+
run: |
145+
set -ex
146+
147+
rm -rf tmp
148+
mkdir tmp
149+
mkdir dist
150+
151+
for dir in bins-* ; do
152+
platform=${dir#"bins-"}
153+
unset exe
154+
if [[ $platform =~ "windows" ]]; then
155+
exe=".exe"
156+
fi
157+
pkgname=$PROJECT_NAME-$TAG-$platform
158+
mkdir tmp/$pkgname
159+
# cp LICENSE README.md tmp/$pkgname
160+
mv bins-$platform/$BIN_NAME$exe tmp/$pkgname
161+
chmod +x tmp/$pkgname/$BIN_NAME$exe
162+
163+
if [ "$exe" = "" ]; then
164+
tar cJf dist/$pkgname.tar.xz -C tmp $pkgname
165+
else
166+
(cd tmp && 7z a -r ../dist/$pkgname.zip $pkgname)
167+
fi
168+
done
169+
170+
- name: Upload binaries to release
171+
uses: svenstaro/upload-release-action@v2
172+
with:
173+
repo_token: ${{ secrets.GITHUB_TOKEN }}
174+
file: dist/*
175+
file_glob: true
176+
tag: ${{ steps.tagname.outputs.val }}
177+
overwrite: true
178+
179+
- name: Extract version
180+
id: extract-version
181+
run: |
182+
printf "::set-output name=%s::%s\n" tag-name "${GITHUB_REF#refs/tags/}"
183+
184+
- uses: mislav/bump-homebrew-formula-action@v1
185+
with:
186+
formula-path: ${{env.PROJECT_NAME}}.rb
187+
homebrew-tap: ${{ env.BREW_TAP }}
188+
download-url: "https://github.com/${{ env.REPO_NAME }}/releases/download/${{ steps.extract-version.outputs.tag-name }}/${{env.PROJECT_NAME}}-${{ steps.extract-version.outputs.tag-name }}-x86_64-macos.tar.xz"
189+
commit-message: updating formula for ${{ env.PROJECT_NAME }}
190+
env:
191+
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}
192+
#
193+
# you can use this initial file in your homebrew-tap if you don't have an initial formula:
194+
# <projectname>.rb
195+
#
196+
# class <Projectname capitalized> < Formula
197+
# desc "A test formula"
198+
# homepage "http://www.example.com"
199+
# url "-----"
200+
# version "-----"
201+
# sha256 "-----"
202+
203+
# def install
204+
# bin.install "<bin-name>"
205+
# end
206+
# end
207+
208+
209+
# Uncomment this section if you want to release your package to crates.io
210+
# Before publishing, make sure you have filled out the following fields:
211+
# license or license-file, description, homepage, documentation, repository, readme.
212+
# Read more: https://doc.rust-lang.org/cargo/reference/publishing.html
213+
214+
# - name: Install ${{ matrix.rust }} toolchain
215+
# uses: actions-rs/toolchain@v1
216+
# with:
217+
# profile: minimal
218+
# toolchain: ${{ matrix.rust }}
219+
# target: ${{ matrix.target }}
220+
# - run: cargo publish --token ${CRATES_TOKEN}
221+
# env:
222+
# CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
223+

.github/workflows/rust.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)