2021-02-01 19:06:12 +03:00
name : release
2021-01-30 00:30:13 +03:00
2022-11-03 18:10:38 +03:00
on :
workflow_dispatch :
inputs :
2022-11-10 18:17:29 +03:00
set-release-version :
2023-06-02 12:32:34 +03:00
description : 'Desired delivery version (x.y.z)'
2022-11-03 18:10:38 +03:00
required : true
type : string
2021-01-30 00:30:13 +03:00
2022-11-03 18:10:38 +03:00
concurrency : release
2021-01-30 00:30:13 +03:00
jobs :
2022-11-10 18:17:29 +03:00
set-context :
2022-11-03 18:10:38 +03:00
env :
GITHUB_CONTEXT : ${{ toJson(github) }}
2022-11-14 18:24:52 +03:00
GITHUB_TOKEN : ${{ secrets.HURL_BOT_TOKEN }}
2022-11-03 18:10:38 +03:00
outputs :
release_version : ${{ steps.set-release-version.outputs.release_version }}
release_branch : ${{ steps.set-release-branch.outputs.release_branch }}
2022-11-10 18:17:29 +03:00
name : set-context
2022-10-05 17:20:25 +03:00
runs-on : ubuntu-latest
steps :
2022-11-03 18:10:38 +03:00
- name : Check trigger branch
run : |
2022-11-10 18:17:29 +03:00
if [ $(echo "${{ github.ref_name }}" | grep -Ec "^master$|^release/") -eq 1 ] ; then
echo " - ✅ The branch triggering this workflow is ${{ github.ref_name }}."
2022-11-03 18:10:38 +03:00
else
2023-06-02 12:32:34 +03:00
echo " - ❌ The branch triggering this workflow is ${{ github.ref_name }} instead of master or release/[0-9].[0-9].[0-9]."
2022-11-03 18:10:38 +03:00
exit 1
fi
- name : Set release version
id : set-release-version
run : |
2022-11-10 18:17:29 +03:00
echo "release_version=${{ github.event.inputs.set-release-version }}" | tee -a $GITHUB_OUTPUT
2022-11-03 18:10:38 +03:00
- name : Set release branch
id : set-release-branch
2022-10-05 17:20:25 +03:00
run : |
2022-11-10 18:17:29 +03:00
if [ $(echo "${{ github.ref_name }}" | grep -c "^release/") -eq 1 ] ; then
echo "release_branch=${{ github.ref_name }}" | tee -a $GITHUB_OUTPUT
else
echo "release_branch=release/${{ github.event.inputs.set-release-version }}" | tee -a $GITHUB_OUTPUT
fi
2022-11-03 18:10:38 +03:00
clean-release :
2022-11-10 18:17:29 +03:00
needs : set-context
2022-11-03 18:10:38 +03:00
env :
GITHUB_CONTEXT : ${{ toJson(github) }}
2022-11-14 18:24:52 +03:00
GITHUB_TOKEN : ${{ secrets.HURL_BOT_TOKEN }}
2022-11-03 18:10:38 +03:00
name : clean-release
2022-10-06 14:43:07 +03:00
runs-on : ubuntu-latest
steps :
2022-11-03 18:10:38 +03:00
- name : Checkout repository
2023-09-16 23:27:09 +03:00
uses : actions/checkout@v4
2022-11-03 18:10:38 +03:00
- name : Check release pull request existence
id : check-release-pull-request-existence
2022-10-06 14:43:07 +03:00
run : |
2022-11-10 18:17:29 +03:00
actual_pr_number=$(gh pr list --repo "${{ github.repository }}" --head "${{ needs.set-context.outputs.release_branch }}" --state "open" --json number --jq .[].number)
2022-11-03 18:10:38 +03:00
actual_pr_number=${actual_pr_number:-0}
echo "actual_pr_number=${actual_pr_number}" | tee -a "${GITHUB_OUTPUT}"
if [ ${actual_pr_number} -eq 0 ] ; then
echo " - ✅ There is no pull request."
echo "release_pr_exists=false" | tee -a $GITHUB_OUTPUT
else
echo " - ✅ Actual pull request number is ${actual_pr_number}."
echo "release_pr_exists=true" | tee -a $GITHUB_OUTPUT
fi
- name : Close actual pull request
if : steps.check-release-pull-request-existence.outputs.release_pr_exists == 'true'
run : |
comment=" - ✅ Pull request n°${{ steps.check-release-pull-request-existence.outputs.actual_pr_number }} closed before opening new one."
gh pr close "${{ steps.check-release-pull-request-existence.outputs.actual_pr_number }}" --comment "${comment}" --delete-branch && gh_exit_code=0 || gh_exit_code=$?
if [ ${gh_exit_code} -eq 0 ] ; then
echo " - ${comment}"
else
comment=" - ❌ A problem occurs when attempting to close PR n°${{ steps.check-release-pull-request-existence.outputs.actual_pr_number }}."
gh pr comment "${{ steps.check-release-pull-request-existence.outputs.actual_pr_number }}" --body "${comment} Please refer to ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID} logs."
echo " - ${comment}"
exit 1
fi
2023-05-04 12:35:10 +03:00
- name : Check GitHub release existence
2022-11-03 18:10:38 +03:00
id : check-github-release-existence
run : |
gh release list || true
2022-11-10 18:17:29 +03:00
escaped_version=$(echo "${{ needs.set-context.outputs.release_version }}" | sed "s#\.#\\\.#g")
2022-11-03 18:10:38 +03:00
github_release_exists=$(gh release list | (grep -c "${escaped_version}" || true))
if [ ${github_release_exists} -eq 0 ] ; then
2022-11-10 18:17:29 +03:00
echo " - ✅ Github release ${{ needs.set-context.outputs.release_version }} does not exist."
2022-11-03 18:10:38 +03:00
echo "github_release_exists=false" | tee -a $GITHUB_OUTPUT
else
2022-11-10 18:17:29 +03:00
echo " - ✅ Github release ${{ needs.set-context.outputs.release_version }} already exists on remote."
2022-11-03 18:10:38 +03:00
echo "github_release_exists=true" | tee -a $GITHUB_OUTPUT
fi
2023-05-04 12:35:10 +03:00
- name : Delete GitHub release
2022-11-03 18:10:38 +03:00
if : steps.check-github-release-existence.outputs.github_release_exists == 'true'
run : |
2022-11-10 18:17:29 +03:00
gh release delete ${{ needs.set-context.outputs.release_version }} --yes && gh_exit_code=0 || gh_exit_code=$?
2022-11-03 18:10:38 +03:00
if [ ${gh_exit_code} -eq 0 ] ; then
2023-05-04 12:35:10 +03:00
echo " - ✅ ${{ needs.set-context.outputs.release_version }} GitHub release deleted."
2022-11-03 18:10:38 +03:00
else
2023-05-04 12:35:10 +03:00
echo " - ❌ A problem occurs when attempting to delete ${{ needs.set-context.outputs.release_version }} GitHub release."
2022-11-03 18:10:38 +03:00
exit 1
fi
- name : Check tag existence
id : check-tag-existence
run : |
2022-11-10 18:17:29 +03:00
escaped_version=$(echo "${{ needs.set-context.outputs.release_version }}" | sed "s#\.#\\\.#g")
2022-11-03 18:10:38 +03:00
tag_exists=$(git ls-remote --tags | (grep -c "${escaped_version}" || true))
if [ ${tag_exists} -eq 0 ] ; then
2022-11-10 18:17:29 +03:00
echo " - ✅ The origin/${{ needs.set-context.outputs.release_version }} tag does not exists on remote."
2022-11-03 18:10:38 +03:00
echo "release_tag_exists=false" | tee -a $GITHUB_OUTPUT
else
2022-11-10 18:17:29 +03:00
echo " - ✅ The origin/${{ needs.set-context.outputs.release_version }} tag already exists on remote."
2022-11-03 18:10:38 +03:00
echo "release_tag_exists=true" | tee -a $GITHUB_OUTPUT
fi
- name : Delete release tag
if : steps.check-tag-existence.outputs.release_tag_exists == 'true'
run : |
2022-11-10 18:17:29 +03:00
git push origin --delete ${{ needs.set-context.outputs.release_version }} && git_exit_code=0 || git_exit_code=$?
2022-11-03 18:10:38 +03:00
if [ ${git_exit_code} -eq 0 ] ; then
2022-11-10 18:17:29 +03:00
echo " - ✅ ${{ needs.set-context.outputs.release_version }} tag deleted."
2022-11-03 18:10:38 +03:00
else
2022-11-10 18:17:29 +03:00
echo " - ❌ A problem occurs when attempting to delete ${{ needs.set-context.outputs.release_version }} tag."
2022-11-03 18:10:38 +03:00
exit 1
fi
2022-11-10 18:17:29 +03:00
- name : Check release branch existence
id : check-release-branch-existence
if : github.ref_name == 'master'
2022-11-03 18:10:38 +03:00
run : |
2022-11-10 18:17:29 +03:00
escaped_version=$(echo "${{ needs.set-context.outputs.release_version }}" | sed "s#\.#\\\.#g")
2022-11-03 18:10:38 +03:00
branch_exists=$(git ls-remote | (grep -c "${escaped_version}" || true))
if [ ${branch_exists} -eq 0 ] ; then
2022-11-10 18:17:29 +03:00
echo " - ✅ The origin/${{ needs.set-context.outputs.release_branch }} branch does not exists on remote."
2022-11-03 18:10:38 +03:00
echo "release_branch_exists=false" | tee -a $GITHUB_OUTPUT
else
2022-11-10 18:17:29 +03:00
echo " - ✅ The origin/${{ needs.set-context.outputs.release_branch }} branch already exists on remote."
2022-11-03 18:10:38 +03:00
echo "release_branch_exists=true" | tee -a $GITHUB_OUTPUT
fi
- name : Delete release branch
2022-11-10 18:17:29 +03:00
if : github.ref_name == 'master' && steps.check-release-branch-existence.outputs.release_branch_exists == 'true'
2022-11-03 18:10:38 +03:00
run : |
2022-11-10 18:17:29 +03:00
git push origin --delete ${{ needs.set-context.outputs.release_branch }} && git_exit_code=0 || git_exit_code=$?
2022-11-03 18:10:38 +03:00
if [ ${git_exit_code} -eq 0 ] ; then
2022-11-10 18:17:29 +03:00
echo " - ✅ ${{ needs.set-context.outputs.release_branch }} branch deleted."
2022-11-03 18:10:38 +03:00
else
2022-11-10 18:17:29 +03:00
echo " - ❌ A problem occurs when attempting to delete ${{ needs.set-context.outputs.release_branch }} branch."
2022-11-03 18:10:38 +03:00
exit 1
fi
2023-06-02 12:32:34 +03:00
update-release-branch :
2022-11-03 18:10:38 +03:00
needs :
2022-11-10 18:17:29 +03:00
- set-context
2023-06-02 12:32:34 +03:00
- clean-release
2022-11-03 18:10:38 +03:00
env :
GITHUB_CONTEXT : ${{ toJson(github) }}
2022-11-14 18:24:52 +03:00
GITHUB_TOKEN : ${{ secrets.HURL_BOT_TOKEN }}
2023-06-02 12:32:34 +03:00
name : update-release-branch
2022-10-06 14:51:57 +03:00
runs-on : ubuntu-latest
steps :
2022-11-03 18:10:38 +03:00
- name : Checkout repository
2023-06-02 12:32:34 +03:00
if : github.ref_name == 'master'
2023-09-16 23:27:09 +03:00
uses : actions/checkout@v4
2022-11-03 18:10:38 +03:00
- name : Create release branch
2022-11-10 18:17:29 +03:00
if : github.ref_name == 'master'
2022-11-03 18:10:38 +03:00
id : create-release-branch
2022-10-06 14:51:57 +03:00
run : |
2022-11-10 18:17:29 +03:00
git checkout -b "${{ needs.set-context.outputs.release_branch }}"
git push origin "${{ needs.set-context.outputs.release_branch }}" && git_exit_code=0 || git_exit_code=$?
2022-11-03 18:10:38 +03:00
if [ ${git_exit_code} -eq 0 ] ; then
2022-11-10 18:17:29 +03:00
echo " - ✅ ${{ needs.set-context.outputs.release_branch }} branch created."
2022-11-03 18:10:38 +03:00
else
2022-11-10 18:17:29 +03:00
echo " - ❌ A problem occurs when attempting to create ${{ needs.set-context.outputs.release_branch }} branch."
2022-11-03 18:10:38 +03:00
exit 1
fi
- name : Checkout new release branch
2023-09-16 23:27:09 +03:00
uses : actions/checkout@v4
2022-11-03 18:10:38 +03:00
with :
2022-11-10 18:17:29 +03:00
ref : ${{ needs.set-context.outputs.release_branch }}
2022-11-03 18:10:38 +03:00
2022-12-08 11:58:44 +03:00
- name : Check CHANGELOG
2023-01-25 15:44:52 +03:00
run : |
pip install beautifulsoup4
bin/check/changelog.sh
2022-12-08 11:58:44 +03:00
2022-11-03 18:10:38 +03:00
- name : Update version
run : |
hurl_packages="hurl_core hurl hurlfmt"
for package in ${hurl_packages} ; do
cargo_toml="packages/${package}/Cargo.toml"
2022-11-10 18:17:29 +03:00
sed -i "s/^version.*/version = \"${{ needs.set-context.outputs.release_version }}\"/" "${cargo_toml}"
2022-11-03 18:10:38 +03:00
echo "----------------------------"
echo " > package version for ${cargo_toml}"
echo " $(grep "^version =" "${cargo_toml}")"
for dep_package in ${hurl_packages} ; do
2023-09-16 23:27:09 +03:00
if [ $(grep -c "^${dep_package} =" "${cargo_toml}") -gt 0 ] ; then
2022-11-10 18:17:29 +03:00
sed -i "s/^${dep_package} = { version .*/${dep_package} = { version = \"${{ needs.set-context.outputs.release_version }}\", path = \"..\/${dep_package}\" }/" "${cargo_toml}"
2022-11-03 18:10:38 +03:00
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
2023-02-02 15:38:42 +03:00
- name : Update installation doc
2022-11-03 18:10:38 +03:00
run : |
2023-01-25 15:59:53 +03:00
# TODO: create a dedicated check script
2023-02-02 15:38:42 +03:00
version_doc="docs/installation.md"
old_version=$(grep "apt install" "${version_doc}" | grep "hurl" | cut --delimiter '/' --field 2- | cut --delimiter '_' --field 2)
echo "old_version=${old_version}"
sed -i "s/${old_version}/${{ needs.set-context.outputs.release_version }}/g" "${version_doc}"
grep "${{ needs.set-context.outputs.release_version }}" "${version_doc}"
2022-11-03 18:10:38 +03:00
- 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 create release commits
run : |
2023-02-01 18:11:27 +03:00
git diff --exit-code && diff=false || diff=true
if [ "${diff}" == "true" ] ; then
git commit -am "Create ${{ needs.set-context.outputs.release_version }} release"
git push && git_exit_code=0 || git_exit_code=$?
if [ ${git_exit_code} -eq 0 ] ; then
echo " - ✅ commits pushed to ${{ needs.set-context.outputs.release_branch }}."
else
2023-03-07 17:50:35 +03:00
echo " - ❌ A problem occurs when attempting to push create release commits to ${{ needs.set-context.outputs.release_branch }} branch."
2023-02-01 18:11:27 +03:00
exit 1
fi
2022-11-03 18:10:38 +03:00
else
2023-02-01 18:11:27 +03:00
echo " - ✅ no changes"
2022-11-03 18:10:38 +03:00
fi
- name : Archive artifacts
uses : actions/upload-artifact@v3
if : ${{ always() }}
with :
name : release-changelog
path : |
2022-11-10 18:17:29 +03:00
release_changelog.md
2022-11-03 18:10:38 +03:00
package-release :
needs :
2022-11-10 18:17:29 +03:00
- set-context
2022-11-03 18:10:38 +03:00
- clean-release
2023-06-02 12:32:34 +03:00
- update-release-branch
2022-11-03 18:10:38 +03:00
name : package-release
2022-11-10 18:17:29 +03:00
uses : ./.github/workflows/package.yml
2022-11-03 18:10:38 +03:00
with :
2022-11-10 18:17:29 +03:00
branch : ${{ needs.set-context.outputs.release_branch }}
2022-11-03 18:10:38 +03:00
deliver-github-release :
2021-02-23 19:37:41 +03:00
env :
2022-11-03 18:10:38 +03:00
GITHUB_CONTEXT : ${{ toJson(github) }}
2022-11-14 18:24:52 +03:00
GITHUB_TOKEN : ${{ secrets.HURL_BOT_TOKEN }}
2022-11-03 18:10:38 +03:00
REPO : ${{ github.repository }}
needs :
2022-11-10 18:17:29 +03:00
- set-context
2022-11-03 18:10:38 +03:00
- clean-release
2023-06-02 12:32:34 +03:00
- update-release-branch
2022-11-03 18:10:38 +03:00
- package-release
name : deliver-github-release
runs-on : ubuntu-latest
2021-02-23 19:37:41 +03:00
steps :
2022-11-03 18:10:38 +03:00
- name : Checkout new release branch
2023-09-16 23:27:09 +03:00
uses : actions/checkout@v4
2022-11-03 18:10:38 +03:00
with :
2022-11-10 18:17:29 +03:00
ref : ${{ needs.set-context.outputs.release_branch }}
2022-11-03 18:10:38 +03:00
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
- uses : actions/download-artifact@master
with :
path : artifacts
- name : Push tag
run : |
2022-11-10 18:17:29 +03:00
git tag -a ${{ needs.set-context.outputs.release_version }} -m "Release ${{ needs.set-context.outputs.release_version }}"
2022-11-03 18:10:38 +03:00
git tag -n
git push --tags && git_exit_code=0 || git_exit_code=$?
if [ ${git_exit_code} -eq 0 ] ; then
2022-11-10 18:17:29 +03:00
echo " - ✅ ${{ needs.set-context.outputs.release_version }} tag created."
2022-11-03 18:10:38 +03:00
git fetch
else
2022-11-10 18:17:29 +03:00
echo " - ❌ A problem occurs when attempting to create ${{ needs.set-context.outputs.release_version }} tag."
2022-11-03 18:10:38 +03:00
exit 1
fi
2022-11-07 17:26:50 +03:00
- name : Deliver release
2022-11-03 18:10:38 +03:00
run : |
2022-11-10 18:17:29 +03:00
cat CHANGELOG.md | python3 bin/release/changelog_extract.py ${{ needs.set-context.outputs.release_version }} > release_changelog.md
gh release create ${{ needs.set-context.outputs.release_version }} \
--target ${{ needs.set-context.outputs.release_branch }} \
2022-11-03 18:10:38 +03:00
--notes-file release_changelog.md \
2022-11-10 18:17:29 +03:00
--title ${{ needs.set-context.outputs.release_version }} \
2022-11-03 18:10:38 +03:00
--draft \
2022-11-10 18:17:29 +03:00
artifacts/release-deb-x64-artifacts/hurl_"${{ needs.set-context.outputs.release_version }}"_amd64.deb \
2023-09-20 16:19:56 +03:00
artifacts/release-generic-linux-x64-artifacts/hurl-"${{ needs.set-context.outputs.release_version }}"-x86_64-unknown-linux-gnu.tar.gz \
artifacts/release-macos-x64-artifacts/hurl-"${{ needs.set-context.outputs.release_version }}"-x86_64-apple-darwin.tar.gz \
artifacts/release-windows-x64-artifacts/hurl-"${{ needs.set-context.outputs.release_version }}"-x86_64-pc-windows-msvc-installer.exe \
artifacts/release-windows-x64-artifacts/hurl-"${{ needs.set-context.outputs.release_version }}"-x86_64-pc-windows-msvc.zip && gh_exit_code=0 || gh_exit_code=$?
2022-11-03 18:10:38 +03:00
if [ ${gh_exit_code} -eq 0 ] ; then
2022-11-10 18:17:29 +03:00
echo " - ✅ Github release ${{ needs.set-context.outputs.release_version }} created."
2022-11-03 18:10:38 +03:00
else
2023-05-04 12:35:10 +03:00
echo " - ❌ A problem occurs when attempting to create GitHub release ${{ needs.set-context.outputs.release_version }}."
2022-11-03 18:10:38 +03:00
exit 1
fi
- name : Create new pull request
run : |
2022-11-14 18:24:52 +03:00
GITHUB_TOKEN=${{ secrets.HURL_BOT_TOKEN }}
2022-11-03 18:10:38 +03:00
{
2023-05-04 12:35:10 +03:00
echo "⚠ This is a GitHub releasing PR."
2023-06-29 17:05:31 +03:00
echo "- Please use \`/accept\` as usual then run the \`update-branch-version\` github workflow if you want to automatically update master branch to next SNAPSHOT version"
2022-11-03 18:10:38 +03:00
} > file-body.txt
gh pr create \
2023-05-04 12:35:10 +03:00
--title "Merge GitHub ${{ needs.set-context.outputs.release_branch }} into ${{ github.ref_name }}" \
2022-11-03 18:10:38 +03:00
--body-file file-body.txt \
--base master \
--label bot && gh_exit_code=0 || gh_exit_code=$?
if [ ${gh_exit_code} -eq 0 ] ; then
2022-11-10 18:17:29 +03:00
new_pr_number=$(gh pr list --repo "${{ github.repository }}" --head "${{ needs.set-context.outputs.release_branch }}" --state "open" --json number --jq .[].number)
2022-11-03 18:10:38 +03:00
echo " - ✅ Creation of pull request n°${new_pr_number} succeeds."
else
echo " - ❌ A problem occurs when attempting to create new pull request."
exit 1
fi