From f528112963bbec052a7289abdabb3ff23f543020 Mon Sep 17 00:00:00 2001 From: miro Date: Wed, 11 Sep 2024 03:09:34 +0100 Subject: [PATCH] feat:semver --- .github/workflows/conventional-label.yml | 10 +++ .github/workflows/propose_release.yml | 32 ------- .github/workflows/publish_alpha.yml | 32 ------- .github/workflows/publish_release.yml | 13 --- .github/workflows/publish_stable.yml | 72 +++++++++++++++ .github/workflows/release_workflow.yml | 108 +++++++++++++++++++++++ readme.md => README.md | 0 requirements.txt | 8 +- setup.py | 2 +- 9 files changed, 195 insertions(+), 82 deletions(-) create mode 100644 .github/workflows/conventional-label.yml delete mode 100644 .github/workflows/propose_release.yml delete mode 100644 .github/workflows/publish_alpha.yml delete mode 100644 .github/workflows/publish_release.yml create mode 100644 .github/workflows/publish_stable.yml create mode 100644 .github/workflows/release_workflow.yml rename readme.md => README.md (100%) diff --git a/.github/workflows/conventional-label.yml b/.github/workflows/conventional-label.yml new file mode 100644 index 0000000..9894c1b --- /dev/null +++ b/.github/workflows/conventional-label.yml @@ -0,0 +1,10 @@ +# auto add labels to PRs +on: + pull_request_target: + types: [ opened, edited ] +name: conventional-release-labels +jobs: + label: + runs-on: ubuntu-latest + steps: + - uses: bcoe/conventional-release-labels@v1 diff --git a/.github/workflows/propose_release.yml b/.github/workflows/propose_release.yml deleted file mode 100644 index 7ae03b5..0000000 --- a/.github/workflows/propose_release.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Propose Stable Release -on: - workflow_dispatch: - inputs: - release_type: - type: choice - description: Release Type - options: - - build - - minor - - major -jobs: - update_version: - uses: neongeckocom/.github/.github/workflows/propose_semver_release.yml@master - with: - release_type: ${{ inputs.release_type }} - version_file: ovos_PHAL_plugin_system/version.py - alpha_var: VERSION_ALPHA - build_var: VERSION_BUILD - minor_var: VERSION_MINOR - major_var: VERSION_MAJOR - update_changelog: True - branch: dev - - pull_changes: - needs: update_version - uses: neongeckocom/.github/.github/workflows/pull_master.yml@master - with: - pr_assignee: ${{ github.actor }} - pr_draft: false - pr_title: ${{ needs.update_version.outputs.version }} - pr_body: ${{ needs.update_version.outputs.changelog }} diff --git a/.github/workflows/publish_alpha.yml b/.github/workflows/publish_alpha.yml deleted file mode 100644 index 580a429..0000000 --- a/.github/workflows/publish_alpha.yml +++ /dev/null @@ -1,32 +0,0 @@ -# This workflow will generate a distribution and upload it to PyPI - -name: Publish Alpha Build ...aX -on: - push: - branches: - - dev - paths-ignore: - - 'ovos_PHAL_plugin_system/version.py' - - 'test/**' - - '.github/**' - - '.gitignore' - - 'LICENSE' - - 'CHANGELOG.md' - - 'MANIFEST.in' - - 'readme.md' - - 'scripts/**' - workflow_dispatch: - -jobs: - publish_alpha_release: - uses: neongeckocom/.github/.github/workflows/publish_alpha_release.yml@master - secrets: - PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} - with: - version_file: "ovos_PHAL_plugin_system/version.py" - publish_prerelease: true - update_changelog: true - alpha_var: VERSION_ALPHA - build_var: VERSION_BUILD - minor_var: VERSION_MINOR - major_var: VERSION_MAJOR \ No newline at end of file diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml deleted file mode 100644 index c86812b..0000000 --- a/.github/workflows/publish_release.yml +++ /dev/null @@ -1,13 +0,0 @@ -# This workflow will generate a release distribution and upload it to PyPI - -name: Publish Build and GitHub Release -on: - push: - branches: - - master - -jobs: - build_and_publish_pypi_and_release: - uses: neongeckocom/.github/.github/workflows/publish_stable_release.yml@master - secrets: - PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/publish_stable.yml b/.github/workflows/publish_stable.yml new file mode 100644 index 0000000..0b55ffa --- /dev/null +++ b/.github/workflows/publish_stable.yml @@ -0,0 +1,72 @@ +name: Stable Release +on: + push: + branches: [master] + workflow_dispatch: + +jobs: + publish_stable: + uses: TigreGotico/gh-automations/.github/workflows/publish-stable.yml@master + secrets: inherit + with: + branch: 'master' + version_file: 'ovos_PHAL_plugin_system/version.py' + setup_py: 'setup.py' + publish_release: true + + publish_pypi: + needs: publish_stable + if: success() # Ensure this job only runs if the previous job succeeds + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: dev + fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - name: Install Build Tools + run: | + python -m pip install build wheel + - name: version + run: echo "::set-output name=version::$(python setup.py --version)" + id: version + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: V${{ steps.version.outputs.version }} + release_name: Release ${{ steps.version.outputs.version }} + body: | + Changes in this Release + ${{ steps.changelog.outputs.changelog }} + draft: false + prerelease: true + commitish: dev + - name: Build Distribution Packages + run: | + python setup.py sdist bdist_wheel + - name: Publish to Test PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{secrets.PYPI_TOKEN}} + + + sync_dev: + needs: publish_stable + if: success() # Ensure this job only runs if the previous job succeeds + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. + ref: master + - name: Push master -> dev + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: dev \ No newline at end of file diff --git a/.github/workflows/release_workflow.yml b/.github/workflows/release_workflow.yml new file mode 100644 index 0000000..7f2cf02 --- /dev/null +++ b/.github/workflows/release_workflow.yml @@ -0,0 +1,108 @@ +name: Release Alpha and Propose Stable + +on: + pull_request: + types: [closed] + branches: [dev] + +jobs: + publish_alpha: + if: github.event.pull_request.merged == true + uses: TigreGotico/gh-automations/.github/workflows/publish-alpha.yml@master + secrets: inherit + with: + branch: 'dev' + version_file: 'ovos_PHAL_plugin_system/version.py' + setup_py: 'setup.py' + update_changelog: true + publish_prerelease: true + changelog_max_issues: 100 + + notify: + if: github.event.pull_request.merged == true + needs: publish_alpha + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Send message to Matrix bots channel + id: matrix-chat-message + uses: fadenb/matrix-chat-message@v0.0.6 + with: + homeserver: 'matrix.org' + token: ${{ secrets.MATRIX_TOKEN }} + channel: '!WjxEKjjINpyBRPFgxl:krbel.duckdns.org' + message: | + new ${{ github.event.repository.name }} PR merged! https://github.com/${{ github.repository }}/pull/${{ github.event.number }} + + publish_pypi: + needs: publish_alpha + if: success() # Ensure this job only runs if the previous job succeeds + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: dev + fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - name: Install Build Tools + run: | + python -m pip install build wheel + - name: version + run: echo "::set-output name=version::$(python setup.py --version)" + id: version + - name: Build Distribution Packages + run: | + python setup.py sdist bdist_wheel + - name: Publish to Test PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{secrets.PYPI_TOKEN}} + + + propose_release: + needs: publish_alpha + if: success() # Ensure this job only runs if the previous job succeeds + runs-on: ubuntu-latest + steps: + - name: Checkout dev branch + uses: actions/checkout@v3 + with: + ref: dev + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.10' + + - name: Get version from setup.py + id: get_version + run: | + VERSION=$(python setup.py --version) + echo "VERSION=$VERSION" >> $GITHUB_ENV + + - name: Create and push new branch + run: | + git checkout -b release-${{ env.VERSION }} + git push origin release-${{ env.VERSION }} + + - name: Open Pull Request from dev to master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Variables + BRANCH_NAME="release-${{ env.VERSION }}" + BASE_BRANCH="master" + HEAD_BRANCH="release-${{ env.VERSION }}" + PR_TITLE="Release ${{ env.VERSION }}" + PR_BODY="Human review requested!" + + # Create a PR using GitHub API + curl -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: token $GITHUB_TOKEN" \ + -d "{\"title\":\"$PR_TITLE\",\"body\":\"$PR_BODY\",\"head\":\"$HEAD_BRANCH\",\"base\":\"$BASE_BRANCH\"}" \ + https://api.github.com/repos/${{ github.repository }}/pulls + diff --git a/readme.md b/README.md similarity index 100% rename from readme.md rename to README.md diff --git a/requirements.txt b/requirements.txt index 7414fc2..b35f571 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -ovos-plugin-manager>=0.0.26a10 -ovos-utils~=0.0, >=0.1.0a15 -ovos_config~=0.0, >=0.0.5 -ovos-bus-client~=0.0.8 +ovos-plugin-manager>=0.0.26,<1.0.0 +ovos-utils>=0.1.0,<1.0.0 +ovos_config>=0.0.5,<1.0.0 +ovos-bus-client>=0.0.8,<1.0.0 diff --git a/setup.py b/setup.py index 971f024..d20cd1f 100755 --- a/setup.py +++ b/setup.py @@ -51,7 +51,7 @@ def required(requirements_file): def get_description(): - with open(os.path.join(BASEDIR, "readme.md"), "r") as f: + with open(os.path.join(BASEDIR, "README.md"), "r") as f: long_description = f.read() return long_description