-
Notifications
You must be signed in to change notification settings - Fork 3
117 lines (97 loc) · 3.14 KB
/
publish.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
name: Publish
on:
workflow_dispatch:
env:
RUST_CACHE_GUID: '65563088-aab0-4cae-8300-60357a37fc04'
jobs:
publish:
name: Publish
strategy:
matrix:
os: [ubuntu-latest]
rust_toolchain: [stable]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: install rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust_toolchain }}
components: rust-src
override: true
- name: cache rust
uses: Swatinem/rust-cache@v2
with:
workspaces: |
. -> target
shared-key: ${{ env.RUST_CACHE_GUID }}
- name: install cargo-audit
run: cargo install cargo-audit
- name: cargo audit
uses: gh640/command-result-action@v1
id: cargo_audit
with:
command: 'cargo audit'
cwd: '.'
- name: remove ansi color escape sequences
uses: marcransome/remove-ansi-colors@v1
id: cargo_audit_escaped
with:
colored: ${{ steps.cargo_audit.outputs.stdout }}
- name: publish
run: |
cargo publish --token ${{ secrets.CRATES_TOKEN }} -p ntstatus
- name: lookup release version
id: version
uses: thebongy/version-check@v1
with:
file: './Cargo.toml'
- name: tag action
id: tag
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: '${{ secrets.GITHUB_TOKEN }}'
custom_tag: '${{ steps.version.outputs.releaseVersion }}'
- name: push tag
run: git push origin --tags
- name: generate changelog
id: changelog
uses: requarks/changelog-action@v1
with:
token: '${{ github.token }}'
tag: '${{ steps.version.outputs.releaseVersion }}'
writeToFile: false
includeInvalidCommits: true
- name: encode changelog
id: changelog_encoded
uses: kkent030315/actions-base64-encode@main
with:
data: ${{ steps.changelog.outputs.changelog }}
- name: create release
id: release
uses: actions/github-script@v4
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
script: |
const encoded = '${{ steps.changelog_encoded.outputs.result }}';
const changelog = Buffer.from(encoded, 'base64').toString('utf8');
const response = await octokit.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: `${{ steps.version.outputs.releaseVersion }}`,
name: `${{ steps.version.outputs.releaseVersion }}`,
body: `# 📣 Releasing v${{ steps.version.outputs.releaseVersion }}
${changelog}
---
<details>
<summary>Cargo Audit</summary>
```
${{ steps.cargo_audit_escaped.outputs.uncolored }}
```
</details>`,
draft: false,
prerelease: false
});
return response.data.number