-
Notifications
You must be signed in to change notification settings - Fork 54
92 lines (75 loc) · 2.23 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
name: Release
on:
push:
tags:
- v*.*.*
jobs:
test:
name: Test
uses: KonishchevDmitry/investments/.github/workflows/test.yml@master
build:
name: Build for ${{ matrix.os }}
runs-on: ${{ format('{0}-latest', matrix.os) }}
strategy:
matrix:
include:
- os: ubuntu
binary_name: investments
archive_ext: tar.bz2
- os: macos
binary_name: investments
archive_ext: tar.bz2
- os: windows
binary_name: investments.exe
archive_ext: zip
steps:
- uses: actions/checkout@v3
- name: Build
env:
CARGO_TERM_COLOR: always
INVESTMENTS_PRECOMPILED_BINARY: yes
run: cargo build --release --locked
- name: Construct archive name
id: archive_name
uses: ASzc/change-string-case-action@v5
with:
string: ${{ format('investments-{0}-{1}-{2}.{3}', runner.os, runner.arch, github.ref_name, matrix.archive_ext) }}
- name: Create archive
shell: bash
run: |
set -eu
# A workaround for https://github.com/actions/virtual-environments/issues/2619
if [ "$(uname)" = Darwin ]; then
sudo purge
alias tar=gtar
fi
binary_name="${{ matrix.binary_name }}"
archive_name="${{ steps.archive_name.outputs.lowercase }}"
mv "target/release/$binary_name" .
case "$archive_name" in
*.tar.bz2) tar -cjf "$archive_name" "$binary_name";;
*.zip) 7z a "$archive_name" "$binary_name";;
*) echo "Unexpected archive name: $archive_name." >&2; exit 1;;
esac
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: ${{ steps.archive_name.outputs.lowercase }}
if-no-files-found: error
retention-days: 1
publish:
name: Publish
needs: [test, build]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Create release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
file: artifacts/*/*
file_glob: true