hurl/.github/workflows/update-branch-version.yml

130 lines
5.0 KiB
YAML
Raw Normal View History

2022-11-03 18:10:38 +03:00
name: update-branch-version
on:
workflow_dispatch:
inputs:
new_version:
2022-11-10 18:17:29 +03:00
description: 'Version (x.y.z-SNASPHOT)'
2022-11-03 18:10:38 +03:00
required: true
type: string
workflow_call:
secrets:
HURL_BOT_TOKEN:
description: 'secrets.HURL_BOT_TOKEN from the caller workflow'
2022-11-03 18:10:38 +03:00
required: true
2022-11-16 11:40:57 +03:00
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
2022-11-03 18:10:38 +03:00
inputs:
new_version:
2022-11-10 18:17:29 +03:00
description: "Version (x.y.z-SNASPHOT)"
2022-11-03 18:10:38 +03:00
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 }}
2022-11-03 18:10:38 +03:00
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@v4
2022-11-03 18:10:38 +03:00
with:
ref: ${{ inputs.branch }}
- name: Init bot branch name
2022-11-03 18:10:38 +03:00
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
2022-11-03 18:10:38 +03:00
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
2022-11-16 11:40:57 +03:00
- 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: "bot@hurl.dev"
git_user_signingkey: true
git_commit_gpgsign: true
2022-11-03 18:10:38 +03:00
- 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
2023-03-07 17:50:35 +03:00
echo " - ❌ A problem occurs when attempting to push create release commits to ${BOT_UPDATE_VERSION_BRANCHE_NAME} branch."
2022-11-03 18:10:38 +03:00
exit 1
fi
- name: Create new version PR
id: create-new-version-pr
run: |
GITHUB_TOKEN=${{ secrets.HURL_BOT_TOKEN }}
2022-11-03 18:10:38 +03:00
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