mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-30 00:37:52 +03:00
376 lines
17 KiB
YAML
376 lines
17 KiB
YAML
name: release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
control-release-version:
|
|
description: 'Control release version'
|
|
required: true
|
|
type: string
|
|
create-release-branch:
|
|
description: 'Create release branch'
|
|
required: true
|
|
type: boolean
|
|
default: true
|
|
deliver-github-release:
|
|
description: 'Deliver github release'
|
|
required: true
|
|
type: boolean
|
|
default: true
|
|
|
|
concurrency: release
|
|
|
|
jobs:
|
|
control-release:
|
|
if: github.event.inputs.create-release-branch == 'true'
|
|
env:
|
|
GITHUB_CONTEXT: ${{ toJson(github) }}
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
outputs:
|
|
release_version: ${{ steps.set-release-version.outputs.release_version }}
|
|
release_branch: ${{ steps.set-release-branch.outputs.release_branch }}
|
|
name: control-release
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
with:
|
|
ref: master
|
|
|
|
- name: Check trigger branch
|
|
run: |
|
|
if [ "${{ github.ref_name }}" == "master" ] ; then
|
|
echo " - ✅ The branch triggering this workflow is master."
|
|
else
|
|
echo " - ❌ The branch triggering this workflow is ${{ github.ref_name }} instead of master."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Set release version
|
|
id: set-release-version
|
|
run: |
|
|
actual_version=$(grep -E "^version" packages/hurl/Cargo.toml | cut --delimiter "=" --field 2 | tr -d '" ')
|
|
echo "actual_version=${actual_version}" | tee -a $GITHUB_OUTPUT
|
|
release_version=$(echo "${actual_version}" | cut --delimiter "-" --field 1)
|
|
echo "release_version=${release_version}" | tee -a $GITHUB_OUTPUT
|
|
|
|
- name: Set release branch
|
|
id: set-release-branch
|
|
run: |
|
|
echo "release_branch=release/${{ steps.set-release-version.outputs.release_version }}" | tee -a $GITHUB_OUTPUT
|
|
|
|
- name: Control release version
|
|
run: |
|
|
if [ "${{ github.event.inputs.control-release-version }}" == "${{ steps.set-release-version.outputs.release_version }}" ] ; then
|
|
echo " - ✅ Desired release version ${{ github.event.inputs.control-release-version }} equals version ${{ steps.set-release-version.outputs.release_version }} getted from package/hurl/Cargo.toml on master."
|
|
else
|
|
echo " - ❌ Desired release version ${{ github.event.inputs.control-release-version }} do not equals version ${{ steps.set-release-version.outputs.release_version }} getted from package/hurl/Cargo.toml on master."
|
|
exit 1
|
|
fi
|
|
|
|
clean-release:
|
|
if: github.event.inputs.create-release-branch == 'true'
|
|
needs: control-release
|
|
env:
|
|
GITHUB_CONTEXT: ${{ toJson(github) }}
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
name: clean-release
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
with:
|
|
ref: master
|
|
|
|
- name: Check release pull request existence
|
|
id: check-release-pull-request-existence
|
|
run: |
|
|
actual_pr_number=$(gh pr list --repo "${{ github.repository }}" --head "${{ needs.control-release.outputs.release_branch }}" --state "open" --json number --jq .[].number)
|
|
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
|
|
|
|
- name: Check github release existence
|
|
id: check-github-release-existence
|
|
run: |
|
|
gh release list || true
|
|
escaped_version=$(echo "${{ needs.control-release.outputs.release_version }}" | sed "s#\.#\\\.#g")
|
|
github_release_exists=$(gh release list | (grep -c "${escaped_version}" || true))
|
|
if [ ${github_release_exists} -eq 0 ] ; then
|
|
echo " - ✅ Github release ${{ needs.control-release.outputs.release_version }} does not exist."
|
|
echo "github_release_exists=false" | tee -a $GITHUB_OUTPUT
|
|
else
|
|
echo " - ✅ Github release ${{ needs.control-release.outputs.release_version }} already exists on remote."
|
|
echo "github_release_exists=true" | tee -a $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Delete github release
|
|
if: steps.check-github-release-existence.outputs.github_release_exists == 'true'
|
|
run: |
|
|
gh release delete ${{ needs.control-release.outputs.release_version }} --yes && gh_exit_code=0 || gh_exit_code=$?
|
|
if [ ${gh_exit_code} -eq 0 ] ; then
|
|
echo " - ✅ ${{ needs.control-release.outputs.release_version }} github release deleted."
|
|
else
|
|
echo " - ❌ A problem occurs when attempting to delete ${{ needs.control-release.outputs.release_version }} github release."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Check tag existence
|
|
id: check-tag-existence
|
|
run: |
|
|
escaped_version=$(echo "${{ needs.control-release.outputs.release_version }}" | sed "s#\.#\\\.#g")
|
|
tag_exists=$(git ls-remote --tags | (grep -c "${escaped_version}" || true))
|
|
if [ ${tag_exists} -eq 0 ] ; then
|
|
echo " - ✅ The origin/${{ needs.control-release.outputs.release_version }} tag does not exists on remote."
|
|
echo "release_tag_exists=false" | tee -a $GITHUB_OUTPUT
|
|
else
|
|
echo " - ✅ The origin/${{ needs.control-release.outputs.release_version }} tag already exists on remote."
|
|
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: |
|
|
git push origin --delete ${{ needs.control-release.outputs.release_version }} && git_exit_code=0 || git_exit_code=$?
|
|
if [ ${git_exit_code} -eq 0 ] ; then
|
|
echo " - ✅ ${{ needs.control-release.outputs.release_version }} tag deleted."
|
|
else
|
|
echo " - ❌ A problem occurs when attempting to delete ${{ needs.control-release.outputs.release_version }} tag."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Check branch existence
|
|
id: check-branch-existence
|
|
run: |
|
|
escaped_version=$(echo "${{ needs.control-release.outputs.release_version }}" | sed "s#\.#\\\.#g")
|
|
branch_exists=$(git ls-remote | (grep -c "${escaped_version}" || true))
|
|
if [ ${branch_exists} -eq 0 ] ; then
|
|
echo " - ✅ The origin/${{ needs.control-release.outputs.release_branch }} branch does not exists on remote."
|
|
echo "release_branch_exists=false" | tee -a $GITHUB_OUTPUT
|
|
else
|
|
echo " - ✅ The origin/${{ needs.control-release.outputs.release_branch }} branch already exists on remote."
|
|
echo "release_branch_exists=true" | tee -a $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Delete release branch
|
|
if: steps.check-branch-existence.outputs.release_branch_exists == 'true'
|
|
run: |
|
|
git push origin --delete ${{ needs.control-release.outputs.release_branch }} && git_exit_code=0 || git_exit_code=$?
|
|
if [ ${git_exit_code} -eq 0 ] ; then
|
|
echo " - ✅ ${{ needs.control-release.outputs.release_branch }} branch deleted."
|
|
else
|
|
echo " - ❌ A problem occurs when attempting to delete ${{ needs.control-release.outputs.release_branch }} branch."
|
|
exit 1
|
|
fi
|
|
|
|
create-release-branch:
|
|
if: github.event.inputs.create-release-branch == 'true'
|
|
needs:
|
|
- clean-release
|
|
- control-release
|
|
env:
|
|
GITHUB_CONTEXT: ${{ toJson(github) }}
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
name: create-release-branch
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
with:
|
|
ref: master
|
|
|
|
- name: Create release branch
|
|
id: create-release-branch
|
|
run: |
|
|
git checkout -b "${{ needs.control-release.outputs.release_branch }}"
|
|
git push origin "${{ needs.control-release.outputs.release_branch }}" && git_exit_code=0 || git_exit_code=$?
|
|
if [ ${git_exit_code} -eq 0 ] ; then
|
|
echo " - ✅ ${{ needs.control-release.outputs.release_branch }} branch created."
|
|
else
|
|
echo " - ❌ A problem occurs when attempting to create ${{ needs.control-release.outputs.release_branch }} branch."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Checkout new release branch
|
|
uses: actions/checkout@v3
|
|
with:
|
|
ref: ${{ needs.control-release.outputs.release_branch }}
|
|
|
|
- name: Init git credentials
|
|
run: |
|
|
git config --local user.email "action@github.com"
|
|
git config --local user.name "GitHub Action"
|
|
|
|
- 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 = \"${{ needs.control-release.outputs.release_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 = \"${{ needs.control-release.outputs.release_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 packages manuals
|
|
run: |
|
|
version_doc="docs/installation.md"
|
|
old_version=$(grep "sudo dpkg -i" "${version_doc}" | cut --delimiter "_" --field 2 )
|
|
echo "old_version=${old_version}"
|
|
sed -i "s/${old_version}/${{ needs.control-release.outputs.release_version }}/g" "${version_doc}"
|
|
grep "${{ needs.control-release.outputs.release_version }}" "${version_doc}"
|
|
|
|
- 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: Push create release commits
|
|
run: |
|
|
git commit -am "Create ${{ needs.control-release.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.control-release.outputs.release_branch }}."
|
|
else
|
|
echo " - ❌ A problem occurs when attempting to push create relase commits to ${{ needs.control-release.outputs.release_branch }} branch."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Archive artifacts
|
|
uses: actions/upload-artifact@v3
|
|
if: ${{ always() }}
|
|
with:
|
|
name: release-changelog
|
|
path: |
|
|
release_changelog.md
|
|
|
|
package-release:
|
|
needs:
|
|
- clean-release
|
|
- control-release
|
|
- create-release-branch
|
|
name: package-release
|
|
if: github.event.inputs.deliver-github-release == 'true'
|
|
uses: Orange-OpenSource/hurl/.github/workflows/package.yml@master
|
|
with:
|
|
branch: ${{ needs.control-release.outputs.release_branch }}
|
|
|
|
deliver-github-release:
|
|
env:
|
|
GITHUB_CONTEXT: ${{ toJson(github) }}
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
REPO: ${{ github.repository }}
|
|
needs:
|
|
- clean-release
|
|
- control-release
|
|
- create-release-branch
|
|
- package-release
|
|
name: deliver-github-release
|
|
if: github.event.inputs.deliver-github-release == 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout new release branch
|
|
uses: actions/checkout@v3
|
|
with:
|
|
ref: ${{ needs.control-release.outputs.release_branch }}
|
|
|
|
- name: Init git credentials
|
|
run: |
|
|
git config --local user.email "action@github.com"
|
|
git config --local user.name "GitHub Action"
|
|
- uses: actions/download-artifact@master
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Push tag
|
|
run: |
|
|
git tag -a ${{ needs.control-release.outputs.release_version }} -m "Release ${{ needs.control-release.outputs.release_version }}"
|
|
git tag -n
|
|
git push --tags && git_exit_code=0 || git_exit_code=$?
|
|
if [ ${git_exit_code} -eq 0 ] ; then
|
|
echo " - ✅ ${{ needs.control-release.outputs.release_version }} tag created."
|
|
git fetch
|
|
else
|
|
echo " - ❌ A problem occurs when attempting to create ${{ needs.control-release.outputs.release_version }} tag."
|
|
exit 1
|
|
fi
|
|
|
|
- name: deliver release
|
|
run: |
|
|
cat CHANGELOG.md | python3 bin/release/changelog_extract.py ${{ needs.control-release.outputs.release_version }} > release_changelog.md
|
|
gh release create ${{ needs.control-release.outputs.release_version }} \
|
|
--target ${{ needs.control-release.outputs.release_branch }} \
|
|
--notes-file release_changelog.md \
|
|
--draft \
|
|
artifacts/release-deb-x64-artifacts/hurl_"${{ needs.control-release.outputs.release_version }}"_amd64.deb \
|
|
artifacts/release-generic-linux-x64-artifacts/hurl-"${{ needs.control-release.outputs.release_version }}"-x86_64-linux.tar.gz \
|
|
artifacts/release-macos-x64-artifacts/hurl-"${{ needs.control-release.outputs.release_version }}"-x86_64-macos.tar.gz \
|
|
artifacts/release-windows-x64-artifacts/hurl-"${{ needs.control-release.outputs.release_version }}"-win64-installer.exe \
|
|
artifacts/release-windows-x64-artifacts/hurl-"${{ needs.control-release.outputs.release_version }}"-win64.zip && gh_exit_code=0 || gh_exit_code=$?
|
|
if [ ${gh_exit_code} -eq 0 ] ; then
|
|
echo " - ✅ Github release ${{ needs.control-release.outputs.release_version }} created."
|
|
else
|
|
echo " - ❌ A problem occurs when attempting to create github release ${{ needs.control-release.outputs.release_version }}."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Create new pull request
|
|
run: |
|
|
GITHUB_TOKEN=${{ secrets.LEPAPAREIL_CI_TOKEN }}
|
|
{
|
|
echo "⚠ This is a github releasing PR."
|
|
echo "- Please \`/accept\` this PR only when github release ${{ needs.control-release.outputs.release_version }} is published"
|
|
echo "- Please use \`/accept --release\` if you want to automatically update master branch to next SNAPSHOT version"
|
|
} > file-body.txt
|
|
gh pr create \
|
|
--title "Merge github published ${{ needs.control-release.outputs.release_branch }} into master" \
|
|
--body-file file-body.txt \
|
|
--base master \
|
|
--label bot && gh_exit_code=0 || gh_exit_code=$?
|
|
if [ ${gh_exit_code} -eq 0 ] ; then
|
|
new_pr_number=$(gh pr list --repo "${{ github.repository }}" --head "${{ needs.control-release.outputs.release_branch }}" --state "open" --json number --jq .[].number)
|
|
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
|
|
|