-
Notifications
You must be signed in to change notification settings - Fork 7
139 lines (120 loc) · 4.54 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
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.16.0`)'
required: true
type: string
jobs:
release:
env:
CURRENT_VERSION: ${{ github.event.inputs.current_version }}
RELEASE_VERSION: ${{ github.event.inputs.release_version }}
TARGET_BRANCH: main
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
with:
ref: ${{ env.TARGET_BRANCH }}
token: ${{ secrets.GHPAT_FOR_PUSH_RELEASE }}
- 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}"
- 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: Turn off enforce admin
env:
# We wanted to use PAT of SpringQL-bot account but could not.
# SpringQL organization requires 2FA for each member but
# SpringQL-bot does not have an appropriate way to finish 2FA.
#
# So use a PAT from an account eligible as a release manager.
GITHUB_TOKEN: ${{ secrets.GHPAT_FOR_PUSH_RELEASE }}
REPO: ${{ github.repository }}
BRANCH: ${{ env.TARGET_BRANCH }}
run: |
source .github/workflows/scripts/github-branch-protection.bash
enforce_admins_off
- name: git push
run: |
git remote set-url origin "https://github-actions:${{ secrets.GHPAT_FOR_PUSH_RELEASE }}@github.com/${GITHUB_REPOSITORY}"
git push -v --force origin ${{ env.TARGET_BRANCH }}
git push -v --force origin "v${RELEASE_VERSION}"
- name: Turn on enforce admin
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GHPAT_FOR_PUSH_RELEASE }}
REPO: ${{ github.repository }}
BRANCH: ${{ env.TARGET_BRANCH }}
run: |
source .github/workflows/scripts/github-branch-protection.bash
enforce_admins_on
- 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