mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-18 04:52:18 +02:00
ci(common): Support for tagging and releasing in CI
This commit is contained in:
24
.github/workflows/publish-docs-component.yml
vendored
24
.github/workflows/publish-docs-component.yml
vendored
@ -13,18 +13,36 @@ env:
|
|||||||
DOCS_DEPLOY_PATH : ${{ secrets.DOCS_DEPLOY_PATH }}
|
DOCS_DEPLOY_PATH : ${{ secrets.DOCS_DEPLOY_PATH }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docs_build:
|
publish:
|
||||||
name: Docs-Build-And-Upload
|
name: Publish Tag, Release, Docs, Component
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# Skip running on forks since it won't have access to secrets
|
# Skip running on forks since it won't have access to secrets
|
||||||
if: github.repository == 'espressif/esp-protocols'
|
if: github.repository == 'espressif/esp-protocols'
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout esp-protocols
|
- name: Checkout esp-protocols
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
- name: Check for version update
|
||||||
|
shell: bash
|
||||||
|
run: ./ci/detect_component_bump
|
||||||
|
- name: Tag merge commit
|
||||||
|
if: env.BUMP_VERSION != ''
|
||||||
|
uses: anothrNick/github-tag-action@1.61.0
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
CUSTOM_TAG: ${{ env.BUMP_TAG }}
|
||||||
|
- name: Create Release
|
||||||
|
if: env.BUMP_VERSION != ''
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
body_path: "release_notes.md"
|
||||||
|
tag_name: ${{ env.BUMP_TAG }}
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Generate docs
|
- name: Generate docs
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
@ -24,8 +24,8 @@ When releasing a new component version we have to:
|
|||||||
* Deploy the component to component registry
|
* Deploy the component to component registry
|
||||||
* Update the documentation
|
* Update the documentation
|
||||||
|
|
||||||
This process is not fully automated, the first three steps need to be performed manually by project maintainers running the `bump` command (from within this repository, rather than forks, to publish the release `tag`). Release procedure is as follows:
|
This process is not fully automated, the first step needs to be performed manually by project maintainers running the `bump` command. Release procedure is as follows:
|
||||||
* Create a branch in this repository (not from fork)
|
* Run `ci/bump [component] [version]` (version number is optional, `cz` would automatically increment it if not present)
|
||||||
* Run `cz bump [version]` (version number is optional, `cz` would automatically increment it if not present)
|
* Check the updated `CHANGELOG.md` and the generated bump commit message
|
||||||
* Check the updated `CHANGELOG.md`
|
* Create a PR
|
||||||
* Create and merge the branch to master
|
Once the PR is merged, the CI job tags the merge commit, creates a new release, builds and deploys documentation and the new component to the component registry
|
||||||
|
23
ci/bump
Executable file
23
ci/bump
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Usage: bump component [version]"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
comp=$1; shift;
|
||||||
|
|
||||||
|
cd components/${comp}
|
||||||
|
if ! cz bump --dry-run; then
|
||||||
|
echo "Commitizen bump commad failed!"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
cz_bump_out=`cz bump --files-only "$@"`
|
||||||
|
commit_title=`echo "${cz_bump_out}" | head -1`
|
||||||
|
commit_body=`cat ../../release_notes.txt`
|
||||||
|
|
||||||
|
git add -u .
|
||||||
|
git commit -m $"${commit_title}
|
||||||
|
|
||||||
|
${commit_body}"
|
@ -93,6 +93,13 @@ def main():
|
|||||||
updated_changelog.write(orig_items)
|
updated_changelog.write(orig_items)
|
||||||
git.add(filename)
|
git.add(filename)
|
||||||
|
|
||||||
|
# write the current changelog entry to a local text file (removing links, captions and extra newlines)
|
||||||
|
changelog = re.sub(r'\[([^\]]+)\]\([^\)]+\)', r'\1', changelog)
|
||||||
|
changelog = re.sub(r'\#\#[\#\s]*(.+)', r'\1', changelog)
|
||||||
|
changelog = re.sub(r'\n\n', '\n', changelog)
|
||||||
|
with open(os.path.join(root_path, 'release_notes.txt'), 'w') as release_notes:
|
||||||
|
release_notes.write(changelog)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
36
ci/detect_component_bump
Executable file
36
ci/detect_component_bump
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if ! git show -s | grep -q '^Merge'; then
|
||||||
|
echo "Not a merge commit"
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
|
||||||
|
for comp in `ls components`; do
|
||||||
|
if git log -1 -m --name-only --pretty="" | grep -q components/${comp}/idf_component.yml; then
|
||||||
|
echo "${comp}: Component version has been updated"
|
||||||
|
version=`grep version: components/${comp}/.cz.yaml`
|
||||||
|
version=${version#*version: }
|
||||||
|
|
||||||
|
tag_format=`grep tag_format: components/${comp}/.cz.yaml`
|
||||||
|
tag_format=${tag_format#*tag_format: }
|
||||||
|
|
||||||
|
eval tag=$tag_format
|
||||||
|
|
||||||
|
# creates release notes from the last entry (between first two "## sections")
|
||||||
|
awk '/^## \[/{a++};{if(a==1){print}}' components/${comp}/CHANGELOG.md > release_notes.md
|
||||||
|
|
||||||
|
echo "BUMP_VERSION=${version}"
|
||||||
|
echo "BUMP_COMPONENT=${comp}"
|
||||||
|
echo "BUMP_TAG=${tag}"
|
||||||
|
|
||||||
|
# export the findings to github env, so it could be used in other jobs
|
||||||
|
echo "BUMP_VERSION=${version}" >> "$GITHUB_ENV"
|
||||||
|
echo "BUMP_COMPONENT=${comp}" >> "$GITHUB_ENV"
|
||||||
|
echo "BUMP_TAG=${tag}" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "No changes in component version file"
|
Reference in New Issue
Block a user