-
Notifications
You must be signed in to change notification settings - Fork 181
70 lines (61 loc) · 2.43 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
name: Publish
on:
workflow_dispatch: # We can add version input when 1.0 is released and scheduled releases are removed
schedule:
- cron: "0 0 * * 0" # midnight UTC on Sunday
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ssh-key: ${{ secrets.PUBLISH_DEPLOY_KEY }}
fetch-depth: 0
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Install cargo-workspaces
uses: actions-rs/[email protected]
with:
crate: cargo-workspaces
version: 0.2.44
- name: Install Node (for changelog generation)
uses: actions/setup-node@v2
with:
node-version: 16
- name: Release
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
shell: bash
run: |
# Check if we can skip releasing a new version
# (there are no changes and the job was not manually triggered)
export CHANGED=$(cargo workspaces changed --include-merged-tags --ignore-changes "**/Cargo.toml")
if [[ -z "$CHANGED" && "$GITHUB_EVENT_NAME" != "workflow_dispatch" ]]; then
# Nothing has changed, so don't publish a new version
echo "No changes detected, skipping publish."
exit 0
fi
# Update version
git config --global user.email "[email protected]"
git config --global user.name "Github Action"
cargo workspaces -v version -ay --force '*' --include-merged-tags --no-git-commit --exact patch
export VERSION=$(cargo pkgid | sed -E 's/.*#(.*)/\1/g')
# Update changelog
npm install -g [email protected]
auto-changelog --output RELEASES.md \
--starting-version v0.11.0 \
--latest-version "$VERSION" \
--merge-pattern 'Auto merge of #(\d+) - .+\n\n(.+)' \
--template releases-template.hbs
# Commit and publish
git commit -am "Release $VERSION"
git tag "v$VERSION"
cargo workspaces -v publish --from-git --skip-published
git push --tags
cargo workspaces -v version -ay --force '*' --include-merged-tags --no-git-tag --pre-id dev preminor