forked from Orange-OpenSource/hurl
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (118 loc) · 4.98 KB
/
update-branch-version.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
name: update-branch-version
on:
workflow_dispatch:
inputs:
new_version:
description: 'Version (x.y.z-SNASPHOT)'
required: true
type: string
workflow_call:
secrets:
HURL_BOT_TOKEN:
description: 'secrets.HURL_BOT_TOKEN from the caller workflow'
required: true
HURL_BOT_GPG_PRIVATE_KEY:
description: 'secrets.HURL_BOT_GPG_PRIVATE_KEY from the caller workflow'
required: true
HURL_BOT_GPG_PRIVATE_KEY_PASSPHRASE:
description: 'secrets.HURL_BOT_GPG_PRIVATE_KEY_PASSPHRASE from the caller workflow'
required: true
inputs:
new_version:
description: "Version (x.y.z-SNASPHOT)"
required: true
type: string
branch:
description: "ref branch for this workflow"
default: "master"
required: true
type: string
outputs:
pr_number:
description: "Create PR number"
value: ${{ jobs.update-branch-version.outputs.pr_number }}
concurrency: update-branch-version
jobs:
update-branch-version:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
GITHUB_TOKEN: ${{ secrets.HURL_BOT_TOKEN }}
REPO: ${{ github.repository }}
outputs:
pr_number: ${{ steps.create-new-version-pr.outputs.pr_number }}
name: update-branch-version
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ inputs.branch }}
- name: Init bot branch name
run: |
base=$(echo "${{ github.ref }}" | sed "s#refs/heads/##g" | tr '/' '-')
echo "BOT_UPDATE_VERSION_BRANCHE_NAME=bot/update-branch-version-${base}" | tee -a $GITHUB_ENV
- name: Update version
run: |
hurl_packages="hurl_core hurl hurlfmt"
for package in ${hurl_packages} ; do
cargo_toml="packages/${package}/Cargo.toml"
sed -i "s/^version.*/version = \"${{ inputs.new_version }}\"/" "${cargo_toml}"
echo "----------------------------"
echo " > package version for ${cargo_toml}"
echo " $(grep "^version =" "${cargo_toml}")"
for dep_package in ${hurl_packages} ; do
if [ $(grep -c "^${dep_package} =" "${cargo_toml}") -gt 0 ] ; then
sed -i "s/^${dep_package} = { version .*/${dep_package} = { version = \"${{ inputs.new_version }}\", path = \"..\/${dep_package}\" }/" "${cargo_toml}"
echo " > ${dep_package} dep package version for ${cargo_toml}"
echo " $(grep "^${dep_package} =" "${cargo_toml}")"
fi
done
done
- name: Cargo update
run: |
./bin/update_crates.sh
- name: Update man
run: |
for package in hurl hurlfmt ; do
python3 bin/release/gen_manpage.py "docs/manual/${package}.md" > "docs/manual/${package}.1"
done
- name: Update general docs
run: |
python3 bin/docs/build_man_md.py docs/manual/hurl.md > docs/manual.md
python3 bin/docs/build_readme.py github > README.md
python3 bin/docs/build_readme.py crates > packages/hurl/README.md
- name: Init git bot context
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.HURL_BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.HURL_BOT_GPG_PRIVATE_KEY_PASSPHRASE }}
git_committer_name: "hurl-bot"
git_committer_email: "[email protected]"
git_user_signingkey: true
git_commit_gpgsign: true
- name: Push commits
run: |
git checkout -b "${BOT_UPDATE_VERSION_BRANCHE_NAME}"
git commit -am "Update hurl version to ${{ inputs.new_version }}"
git push --set-upstream origin "${BOT_UPDATE_VERSION_BRANCHE_NAME}" && git_exit_code=0 || git_exit_code=$?
if [ ${git_exit_code} -eq 0 ] ; then
echo " - ✅ commits pushed to ${BOT_UPDATE_VERSION_BRANCHE_NAME} branch."
else
echo " - ❌ A problem occurs when attempting to push create relase commits to ${BOT_UPDATE_VERSION_BRANCHE_NAME} branch."
exit 1
fi
- name: Create new version PR
id: create-new-version-pr
run: |
GITHUB_TOKEN=${{ secrets.HURL_BOT_TOKEN }}
git fetch
base=$(echo "${{ github.ref }}" | sed "s#refs/heads/##g")
gh pr create --fill --label bot --base "${base}" --head "${BOT_UPDATE_VERSION_BRANCHE_NAME}" && gh_exit_code=0 || gh_exit_code=$?
if [ ${gh_exit_code} -eq 0 ] ; then
NEW_PR_NUMBER=$(gh pr list --repo "${REPO}" --head "${BOT_UPDATE_VERSION_BRANCHE_NAME}" --state "open" --json number --jq .[].number)
echo " - ✅ Creation of pull request n°${NEW_PR_NUMBER} succeeds."
echo "pr_bumber=${NEW_PR_NUMBER}" | tee -a $GITHUB_OUTPUT
else
echo " - ❌ A problem occurs when attempting to create new pull request."
exit 1
fi