-
Notifications
You must be signed in to change notification settings - Fork 1
191 lines (158 loc) · 5.55 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
---
name: Release Binaries on Tag
on:
push:
tags:
- "v*"
workflow_dispatch:
jobs:
# Check the rust formatting
format:
name: Rust Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Rust Toolchain setup
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Format Check
uses: mbrobbel/rustfmt-check@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
# Build the Linux release artifacts
tag-release-build-linux:
name: Build tag as a release - Linux
runs-on: ubuntu-latest
needs: format
strategy:
matrix:
RUST: [stable]
TARGET:
- x86_64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- aarch64-unknown-linux-gnu
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Toolchain setup
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.RUST }}
target: ${{ matrix.TARGET }}
- name: Cross setup
run: cargo install cross
- name: Test
run: cross test --target=${{ matrix.TARGET }}
- name: Build
run: cross build --release --target=${{ matrix.TARGET }}
- name: Package Release
run: tar cvzf bcd-${{ matrix.TARGET }}.tar.gz --directory=target/${{ matrix.TARGET }}/release bookmark-cd
- name: Generate SHA checksum
run: shasum -a 256 -U bcd-${{ matrix.TARGET }}.tar.gz > bcd-${{ matrix.TARGET }}.sha
- name: Generate MD5 checksum
run: md5sum --tag bcd-${{ matrix.TARGET }}.tar.gz > bcd-${{ matrix.TARGET }}.md5
- name: Upload the artifact with the workflow run
uses: actions/upload-artifact@v3
with:
name: bcd-${{ matrix.TARGET }}-${{ github.ref_name }}
path: bcd-${{ matrix.TARGET }}.*
retention-days: 1
# Build the MacOS release artifacts
tag-release-build-macos:
name: Build tag as a release - MacOS
runs-on: macos-latest
needs: format
strategy:
matrix:
RUST: [stable]
TARGET:
- x86_64-apple-darwin
- aarch64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Toolchain setup
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.RUST }}
target: ${{ matrix.TARGET }}
- name: Cross setup
run: cargo install cross
- name: Test
run: cross test
- name: Build
run: cross build --release --target=${{ matrix.TARGET }}
- name: Package Release
run: tar cvzf bcd-${{ matrix.TARGET }}.tar.gz --directory=target/${{ matrix.TARGET }}/release bookmark-cd
- name: Generate SHA checksum
run: shasum -a 256 -U bcd-${{ matrix.TARGET }}.tar.gz > bcd-${{ matrix.TARGET }}.sha
- name: Generate MD5 checksum
run: md5 bcd-${{ matrix.TARGET }}.tar.gz > bcd-${{ matrix.TARGET }}.md5
- name: Upload the artifact with the workflow run
uses: actions/upload-artifact@v3
with:
name: bcd-${{ matrix.TARGET }}-${{ github.ref_name }}
path: bcd-${{ matrix.TARGET }}.*
retention-days: 1
# Publishing to crates.io - this will be skipped if the tag as a '-' in it for testing purposes
tag-release-publish:
name: Publish tag as a release
runs-on: ubuntu-latest
needs: [tag-release-build-linux, tag-release-build-macos]
if: github.ref_type == 'tag' && ( contains(github.ref_name, '-') == false )
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Publish Application to crates.io
env:
CARGO_REGISTRY_TOKEN: "${{ secrets.CRATES_TOKEN }}"
run: cargo publish
# Package the artifacts as a release package
tag-release-package:
name: Package tag as a release
runs-on: ubuntu-latest
needs: [tag-release-build-linux, tag-release-build-macos]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download all release artifacts from the workflow
uses: actions/download-artifact@v3
- name: Create CLI Release
uses: softprops/action-gh-release@v1
with:
tag_name: "${{ github.ref_name }}"
name: "Release ${{ github.ref_name }}"
token: "${{ secrets.GITHUB_TOKEN }}"
files: |
LICENSE
**/bcd-*.*
# Kick off the workflow in the tap repo (a1ecbr0wn/homebrew-bcd) that will generate the homebrew formula
generate-formula:
name: Initiate the generation of homebrew formula
runs-on: ubuntu-latest
needs: [tag-release-build-linux, tag-release-build-macos]
steps:
- name: Repository Dispatch
uses: benc-uk/workflow-dispatch@v1
with:
token: ${{ secrets.PAT }}
repo: a1ecbr0wn/homebrew-bcd
ref: refs/heads/main
workflow: tap.yml
inputs: '{ "tap_version": "${{ github.ref_name }}" }'
# Kick off the workflow in the snap repo (a1ecbr0wn/snapcraft-bcd) that will generate the snapcraft yaml file
generate-snap:
name: Initiate the generation of the snapcraft yaml file
runs-on: ubuntu-latest
needs: [tag-release-build-linux, tag-release-build-macos]
steps:
- name: Repository Dispatch
uses: benc-uk/workflow-dispatch@v1
with:
token: ${{ secrets.PAT }}
repo: a1ecbr0wn/snapcraft-bcd
ref: refs/heads/main
workflow: snap.yml
inputs: '{ "snap_version": "${{ github.ref_name }}" }'