-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (134 loc) · 4.15 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
name: Test
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
publish-crate:
name: Publish Crate
runs-on: ubuntu-20.04
needs: publish-github-release
steps:
- name: Clone
uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.rustup
target
key: ${{ runner.os }}-stable-min165
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
default: true
components: rustfmt, clippy
- name: Get Version
run: echo GIT_VERSION="$(git describe --tags | sed 's/^v\(.*\)$/\1/')" >> $GITHUB_ENV
- name: Prepare Git
run: |
git config user.email "[email protected]"
git config user.name "Github Actions"
git checkout -b main
# Use throw-away branch so we don't push the changes to origin
git checkout -b deploy_branch
- name: Prepare Crates
run: |
# Update cargo version,
node ./.backstage/version.cjs
git add ./Cargo.toml
# Commit changes so cargo doesn't complain about dirty repo
git commit -m "Deploy changes."
- name: Publish
run: cargo publish --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
publish-github-release:
name: GitHub Release
runs-on: ubuntu-20.04
needs: test
steps:
- name: Get Token
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v2
with:
application_id: ${{ secrets.CC_OSS_BOT_ID }}
application_private_key: ${{ secrets.CC_OSS_BOT_PEM }}
- name: Clone
uses: actions/checkout@v4
with:
token: ${{ steps.get_workflow_token.outputs.token }}
- name: Swap to main
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0 # Full fetch
token: ${{ steps.get_workflow_token.outputs.token }}
- name: Get Version
run: echo GIT_VERSION="$(git describe --tags | sed 's/^v\(.*\)$/\1/')" >> $GITHUB_ENV
- name: Get Tag
run: echo GIT_TAG="$(node ./.backstage/get_tag.cjs)" >> $GITHUB_ENV
- name: Build CHANGELOG
if: env.GIT_TAG == 'latest'
run: |
node ./.backstage/changelog.cjs write
echo CHANGELOG=\"$(base64 -w 0 -i CHANGELOG.md)\" >> $GITHUB_ENV
echo SHA=\"$( git rev-parse main:CHANGELOG.md )\" >> $GITHUB_ENV
- name: Build CHANGELOG
if: env.GIT_TAG != 'latest'
run: |
echo "## Prerelease" > RELEASE.md
node ./.backstage/changelog.cjs write || true
- name: Commit new CHANGELOG
uses: octokit/[email protected]
if: env.GIT_TAG == 'latest'
id: push_changes
with:
route: PUT /repos/{owner}/{repo}/contents/CHANGELOG.md
owner: cloudcannon
repo: matterhorn
branch: main
message: Changelog for ${{ env.GIT_VERSION }}
sha: ${{ env.SHA }}
content: ${{ env.CHANGELOG }}
env:
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
- name: Release
uses: softprops/action-gh-release@v1
with:
repository: cloudcannon/matterhorn
prerelease: false
body_path: RELEASE.md
env:
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
test:
name: Test
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.rustup
target
key: ${{ runner.os }}-${{ matrix.rust }}-min165
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Test Lib
run: cargo test