-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (78 loc) · 3.17 KB
/
cd.yml
File metadata and controls
84 lines (78 loc) · 3.17 KB
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
name: CD
on: workflow_dispatch
env:
CARGO_TERM_COLOR: always
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false # avoid cancelling a deployment partially done
jobs:
check-version:
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.retrieve-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check CHANGELOG.md file exists
run: "[ -f CHANGELOG.md ]"
- name: Check unreleased version is defined in CHANGELOG.md
run: grep '^\#\# \[Unreleased\] - yyyy-mm-dd$' CHANGELOG.md
- name: Check and retrieve version
id: retrieve-version
run: bash .github/workflows/scripts/get_version.sh
publish:
environment: Deployment
runs-on: ubuntu-22.04
needs: check-version
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Retrieve minimal supported rust version
id: rust_version
run: bash .github/workflows/scripts/find_minimal_rust_version.sh
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ steps.rust_version.outputs.RUST_VERSION_STABLE }}
- name: Publish
run: bash .github/workflows/scripts/publish.sh
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
create-release:
environment: Deployment
runs-on: ubuntu-22.04
needs: publish
steps:
- name: Install dependencies
run: sudo apt-get install node-semver -y
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GIT_TOKEN }}
- name: Apply version and date in CHANGELOG.md file
run: sed -i "s/^\#\# \[Unreleased\] - yyyy-mm-dd$/\#\# [${{needs.check-version.outputs.version}}] - $(date +'%Y-%m-%d')/g" CHANGELOG.md
- name: Push changes and create tag
uses: EndBug/add-and-commit@v7
with:
default_author: github_actions
message: Release v${{needs.check-version.outputs.version}}
tag: -a v${{needs.check-version.outputs.version}} -m 'Release v${{needs.check-version.outputs.version}}'
- name: Add section for next version in CHANGELOG.md
run: sed -i '/\#\# \[${{needs.check-version.outputs.version}}\]/i \#\# [Unreleased] - yyyy-mm-dd\n' CHANGELOG.md
- name: Increment version in Cargo.toml
run: bash .github/workflows/scripts/increment_version.sh ${{needs.check-version.outputs.version}}
- name: Push changes
uses: EndBug/add-and-commit@v7
with:
default_author: github_actions
message: Prepare next release
- name: Extract changelog
run: sed -n '/\#\# \[${{needs.check-version.outputs.version}}/,/\#\# \[/p' CHANGELOG.md | sed '/\#\# \[/d' | sed '1{/^$/d}' | sed '1{/^$/d}' | sed '${/^$/d}' | sed '${/^$/d}' > version_changelog.md
- name: Create GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{needs.check-version.outputs.version}}
release_name: v${{needs.check-version.outputs.version}}
body_path: version_changelog.md