-
-
Notifications
You must be signed in to change notification settings - Fork 8
101 lines (88 loc) · 3.16 KB
/
cd.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
name: Continuous Deployment
on:
push:
tags:
- "*"
jobs:
release:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Get version
id: get_version
run: echo ::set-output name=version::${GITHUB_REF/refs\/tags\//}
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
components: clippy
- name: Build Release Mac
if: matrix.os == 'macos-latest'
run: |
cargo build --release
strip target/release/git-cm
mkdir -p release
tar -C ./target/release/ -czvf ./release/git-cm-mac.tar.gz ./git-cm
ls -lisah ./release/git-cm-mac.tar.gz
- name: Build Release Linux
if: matrix.os == 'ubuntu-latest'
run: |
cargo build --release
strip target/release/git-cm
mkdir -p release
tar -C ./target/release/ -czvf ./release/git-cm-linux.tar.gz ./git-cm
- name: Build Release Win
if: matrix.os == 'windows-latest'
run: |
cargo build --release
mkdir -p release
tar -C ./target/release/ -czvf ./release/git-cm-win.tar.gz ./git-cm.exe
- name: Set SHA
if: matrix.os == 'macos-latest'
id: shasum
run: |
echo ::set-output name=sha::"$(shasum -a 256 ./release/git-cm-mac.tar.gz | awk '{printf $1}')"
# - name: Extract release notes
# if: matrix.os == 'ubuntu-latest'
# id: release_notes
# uses: ffurrer2/extract-release-notes@v1
- name: Release
uses: softprops/action-gh-release@v1
with:
# body: ${{ steps.release_notes.outputs.release_notes }}
prerelease: ${{ contains(github.ref, '-') }}
files: |
./release/*.tar.gz
./release/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create new branch to update brew formula
if: "matrix.os == 'macos-latest' && !contains(github.ref, '-')" # skip prereleases
run: git checkout -b chore/${{ github.event.repository.name }}
- name: Bump sirwindfield/homebrew-tap formula
uses: mislav/bump-homebrew-formula-action@v1
if: "matrix.os == 'macos-latest' && !contains(github.ref, '-')" # skip prereleases
env:
COMMITTER_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
with:
homebrew-tap: sirwindfield/homebrew-tap
formula-name: git-cm
base-branch: chore/${{ github.event.repository.name }}
commit-message: |
{{formulaName}} {{version}}
- name: Create Pull Request
if: "matrix.os == 'macos-latest' && !contains(github.ref, '-')" # skip prereleases
uses: peter-evans/[email protected]
with:
delete-branch: true
- name: Publish to crates.io
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/cargo@v1
with:
command: publish
args: --allow-dirty --token ${{ secrets.CRATES_IO_TOKEN }}