-
Notifications
You must be signed in to change notification settings - Fork 7
118 lines (100 loc) · 3.68 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
name: release
on:
workflow_dispatch:
inputs:
current_version:
description: 'current version number (example `0.15.1`)'
required: true
type: string
release_version:
description: 'release version number (example `0.15.1`)'
required: true
type: string
jobs:
release:
env:
CURRENT_VERSION: ${{ github.event.inputs.current_version }}
RELEASE_VERSION: ${{ github.event.inputs.release_version }}
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
with:
ref: main
- name: Show initial git status
run: |
echo '### Initial git status' >> $GITHUB_STEP_SUMMARY
echo '```console' >> $GITHUB_STEP_SUMMARY
git status -v >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: Cache install release tools
id: cache_tools
uses: actions/cache@v2
with:
key: cache_tools_0
path: |
~/.cargo/bin
- name: Install release tools
if: ${{ steps.cache_tools.outputs.cache-hit==false }}
run: |
cargo install cargo-edit toml-cli
- name: git config
run: |
git config --global user.email "action@github.com"
git config --global user.name "SpringQL release script"
- name: edit changelog
run: |
# load helper script
source .github/workflows/scripts/keep-a-changelog.bash
# edit CHANGELOG.md
cp CHANGELOG.md CHANGELOG.md.org
cat CHANGELOG.md.org | bump_changelog "v${CURRENT_VERSION}" "v${RELEASE_VERSION}" > CHANGELOG.md
rm CHANGELOG.md.org
- name: bump crate versions
run: |
cargo set-version -p springql ${RELEASE_VERSION}
cargo set-version -p springql-core ${RELEASE_VERSION}
cd springql
cp Cargo.toml Cargo.toml.org
toml set Cargo.toml.org dependencies.springql-core.version "${RELEASE_VERSION}" > Cargo.toml
rm Cargo.toml.org
cd ..
- name: commit changes
run: |
git add .
git commit -m "update for release v${RELEASE_VERSION}"
- name: Show commit diff
run: |
echo '### Release Commit' >> $GITHUB_STEP_SUMMARY
echo '```diff' >> $GITHUB_STEP_SUMMARY
git diff HEAD^ >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: git tag
run: |
git tag "v${RELEASE_VERSION}"
git tag "springql@${RELASE_VERSION}"
git tag "springql-core@${RELASE_VERSION}"
- name: Show final git status
run: |
echo '### Final git status' >> $GITHUB_STEP_SUMMARY
echo '```console' >> $GITHUB_STEP_SUMMARY
git status -v >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: git push
run: |
git remote set-url origin https://github-actions:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}
git push -v origin main
git push -v origin "v${RELEASE_VERSION}"
git push -v origin "springql@${RELEASE_VERSION}"
git push -v origin "springql-core@${RELEASE_VERSION}"
- name: cargo publish
run: |
# load helper script
source .github/workflows/scripts/crates.io-script.bash
cargo login "${{ secrets.CRATES_IO_TOKEN }}"
cargo publish -p springql-core
wait_published "springql-core" "${RELEASE_VERSION}" 2> /dev/null
cargo publish -p springql
wait_published "springql" "${RELEASE_VERSION}" 2> /dev/null