1+ on :
2+ push :
3+ # Sequence of patterns matched against refs/tags
4+ tags :
5+ - ' v*' # Push events to matching v*, i.e. v1.0, v20.15.10
6+
7+ name : Create Release
8+
9+ env :
10+ # Could, potentially automatically parse
11+ # the bin name, but let's do it automatically for now.
12+ RELEASE_BIN : gh-actions-template
13+
14+ # Space separated paths to include in the archive.
15+ # Start relative paths with a dot if you don't want
16+ # paths to be preserved. Use "/" as a delimiter.
17+ RELEASE_ADDS : README.md LICENSE
18+
19+
20+ jobs :
21+ build :
22+ name : Build release
23+
24+ runs-on : ${{ matrix.os }}
25+ strategy :
26+ matrix :
27+ build : [linux, macos, windows]
28+ include :
29+ - build : linux
30+ os : ubuntu-latest
31+ rust : stable
32+ - build : macos
33+ os : macos-latest
34+ rust : stable
35+ - build : windows
36+ os : windows-latest
37+ rust : stable
38+
39+ steps :
40+ - uses : actions/checkout@v1
41+
42+ - name : Install Rust (rustup)
43+ run : rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }}
44+ if : matrix.os != 'macos-latest'
45+ shell : bash
46+
47+ - name : Install Rust (macos)
48+ # As of 7.12.2019 rust is not installed on MacOS
49+ # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners#macos-1015
50+ run : |
51+ curl https://sh.rustup.rs | sh -s -- -y
52+ echo "##[add-path]$HOME/.cargo/bin"
53+ if : matrix.os == 'macos-latest'
54+
55+ - name : Build
56+ run : cargo build --verbose --release
57+
58+ - name : Create artifact directory
59+ run : mkdir artifacts
60+
61+ - name : Create archive for Linux
62+ run : 7z a -ttar -so -an ./target/release/${{ env.RELEASE_BIN }} ${{ env.RELEASE_ADDS }} | 7z a -si ./artifacts/${{ env.RELEASE_BIN }}-linux-x86_64.tar.gz
63+ if : matrix.os == 'ubuntu-latest'
64+
65+ - name : Create archive for Windows
66+ run : 7z a -tzip ./artifacts/${{ env.RELEASE_BIN }}-windows-x86_64.zip ./target/release/${{ env.RELEASE_BIN }}.exe ${{ env.RELEASE_ADDS }}
67+ if : matrix.os == 'windows-latest'
68+
69+ - name : Install p7zip
70+ # 7Zip not available on MacOS, install p7zip via homebrew.
71+ run : brew install p7zip
72+ if : matrix.os == 'macos-latest'
73+
74+ - name : Create archive for MacOS
75+ run : 7z a -tzip ./artifacts/${{ env.RELEASE_BIN }}-mac-x86_64.zip ./target/release/${{ env.RELEASE_BIN }} ${{ env.RELEASE_ADDS }}
76+ if : matrix.os == 'macos-latest'
77+
78+ # This will double-zip
79+ # See - https://github.com/actions/upload-artifact/issues/39
80+ - uses : actions/upload-artifact@v1
81+ name : Upload archive
82+ with :
83+ name : ${{ runner.os }}
84+ path : artifacts/
0 commit comments