Skip to content

Commit cac6a2c

Browse files
authored
Merge pull request #131 from xsnippet/build-xsnippet-api
Add a CI workflow to build xsnippet-api executables
2 parents b53f77f + a3a9583 commit cac6a2c

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

.github/workflows/release.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
tags:
7+
- "v*"
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
RUSTFLAGS: -Dwarnings
12+
RUST_BACKTRACE: 1
13+
14+
defaults:
15+
run:
16+
shell: bash
17+
18+
jobs:
19+
create_release:
20+
runs-on: ubuntu-latest
21+
outputs:
22+
upload_url: ${{ steps.create_release.outputs.upload_url }}
23+
steps:
24+
- uses: actions/checkout@v2
25+
26+
- id: release_params
27+
run: |
28+
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
29+
echo "::set-output name=prerelease::false"
30+
echo "::set-output name=release_tag::${GITHUB_REF#refs/tags/}"
31+
echo "::set-output name=title::${GITHUB_REF#refs/tags/}"
32+
else
33+
echo "::set-output name=prerelease::true"
34+
echo "::set-output name=release_tag::latest"
35+
echo "::set-output name=title::Development Build"
36+
fi
37+
38+
- id: create_release
39+
uses: "marvinpinto/action-automatic-releases@latest"
40+
with:
41+
repo_token: ${{ secrets.GITHUB_TOKEN }}
42+
prerelease: ${{ steps.release_params.outputs.prerelease }}
43+
automatic_release_tag: ${{ steps.release_params.outputs.release_tag }}
44+
title: ${{ steps.release_params.outputs.title }}
45+
46+
build_assets:
47+
needs: create_release
48+
49+
strategy:
50+
matrix:
51+
os:
52+
- ubuntu-latest
53+
- windows-latest
54+
- macos-latest
55+
rust-version:
56+
- nightly
57+
58+
runs-on: ${{ matrix.os }}
59+
60+
steps:
61+
- uses: actions/checkout@v2
62+
63+
- uses: actions-rs/toolchain@v1
64+
with:
65+
profile: minimal
66+
toolchain: ${{ matrix.rust-version }}
67+
override: true
68+
69+
- uses: ./.github/actions/setup-postgres
70+
71+
- uses: actions-rs/cargo@v1
72+
with:
73+
command: build
74+
args: --release
75+
76+
- run: |
77+
if [ "$RUNNER_OS" == "Windows" ]; then
78+
echo "ASSET_NAME=xsnippet-api-${{ matrix.os }}.exe" >> $GITHUB_ENV
79+
echo "ASSET_PATH=./target/release/xsnippet-api.exe" >> $GITHUB_ENV
80+
else
81+
echo "ASSET_NAME=xsnippet-api-${{ matrix.os }}" >> $GITHUB_ENV
82+
echo "ASSET_PATH=./target/release/xsnippet-api" >> $GITHUB_ENV
83+
fi
84+
85+
- uses: actions/upload-release-asset@v1
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
with:
89+
upload_url: ${{ needs.create_release.outputs.upload_url }}
90+
asset_name: ${{ env.ASSET_NAME }}
91+
asset_path: ${{ env.ASSET_PATH }}
92+
asset_content_type: application/octet-stream

0 commit comments

Comments
 (0)