From b5c70a2ba3a7aa7929853def03a54e825147a69c Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Tue, 14 Nov 2023 15:17:13 -0500 Subject: [PATCH] Update SDK release workflow to use Octorelease Signed-off-by: Timothy Johnson --- .github/workflows/dev-release.yaml | 67 ---------------------------- .github/workflows/sdk-release.yaml | 71 ++++++++++++++++++++++++++++++ release.config.js | 22 +++++++++ 3 files changed, 93 insertions(+), 67 deletions(-) delete mode 100644 .github/workflows/dev-release.yaml create mode 100644 .github/workflows/sdk-release.yaml create mode 100644 release.config.js diff --git a/.github/workflows/dev-release.yaml b/.github/workflows/dev-release.yaml deleted file mode 100644 index 08998350..00000000 --- a/.github/workflows/dev-release.yaml +++ /dev/null @@ -1,67 +0,0 @@ -name: Zowe SDK Release - -on: - pull_request_target: - types: - - closed - branches: - - main - -jobs: - release: - if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release-dev') }} - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - with: - ref: main - token: ${{ secrets.ZOWE_ROBOT_TOKEN }} - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - - name: Increment dev version - id: update-version - shell: python - run: | - import sys - sys.path.append("src") - from _version import __version__ - prerelease_tag = "dev" - tag_end_index = __version__.index(prerelease_tag) + len(prerelease_tag) - new_version = __version__[:tag_end_index] + str(int(__version__[tag_end_index:]) + 1) - with open("src/_version.py", 'w') as f: - f.write("__version__ = \"" + new_version + "\"\n") - print("::set-output name=version::" + new_version) - print("::set-output name=cargo-version::" + "-".join(new_version.rsplit(".", 1))) - - - name: Increment dev version (cargo) - run: cargo install cargo-edit && cargo set-version ${{ steps.update-version.outputs.cargo-version }} - working-directory: src/secrets - - - name: Build dist wheels - run: bash build.sh - - - name: Commit version update - uses: stefanzweifel/git-auto-commit-action@v4 - with: - branch: main - commit_message: "Bump version to ${{ steps.update-version.outputs.version }} [ci skip]" - commit_options: "--signoff" - commit_user_name: ${{ secrets.ZOWE_ROBOT_USER }} - commit_user_email: ${{ secrets.ZOWE_ROBOT_EMAIL }} - file_pattern: "src/_version.py src/secrets/Cargo.*" - tagging_message: v${{ steps.update-version.outputs.version }} - - - name: Publish packages to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_ROBOT_TOKEN }} diff --git a/.github/workflows/sdk-release.yaml b/.github/workflows/sdk-release.yaml new file mode 100644 index 00000000..09dc5d08 --- /dev/null +++ b/.github/workflows/sdk-release.yaml @@ -0,0 +1,71 @@ +name: Zowe SDK Release + +on: + workflow_dispatch: + inputs: + version: + description: Update project version before publish + required: false + type: string + dry-run: + description: Dry run mode + required: false + type: boolean + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Update version + id: update-version + shell: python + run: | + import sys + sys.path.append("src") + from _version import __version__ + new_version = "${{ inputs.version }}" + if new_version: + with open("src/_version.py", 'w') as f: + f.write("__version__ = \"" + new_version + "\"\n") + else: + new_version = __version__ + print("::set-output name=version::" + new_version) + print("::set-output name=cargo-version::" + ("-".join(new_version.rsplit(".", 1)) if new_version.count(".") > 2 else new_version)) + + - name: Update version (cargo) + run: cargo install cargo-edit && cargo set-version ${{ steps.update-version.outputs.cargo-version }} + working-directory: src/secrets + + - name: Build dist wheels + run: bash build.sh + + - name: Archive artifacts + uses: actions/upload-artifact@v3 + with: + path: dist/ + + - uses: zowe-actions/octorelease@feat/add-pypi-plugin + env: + GIT_COMMITTER_NAME: ${{ secrets.ZOWE_ROBOT_USER }} + GIT_COMMITTER_EMAIL: ${{ secrets.ZOWE_ROBOT_EMAIL }} + GIT_CREDENTIALS: x-access-token:${{ secrets.ZOWE_ROBOT_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TWINE_USERNAME: _token_ + TWINE_PASSWORD: ${{ secrets.PYPI_ROBOT_TOKEN }} + with: + dry-run: ${{ inputs.dry-run }} + new-version: ${{ steps.update-version.outputs.version }} diff --git a/release.config.js b/release.config.js new file mode 100644 index 00000000..33027773 --- /dev/null +++ b/release.config.js @@ -0,0 +1,22 @@ +module.exports = { + branches: [ + { + name: "main", + level: "minor" + }, + { + name: "zowe-v?-lts", + level: "patch" + } + // { + // name: "next", + // prerelease: true + // } + ], + plugins: [ + "@octorelease/changelog", + "@octorelease/pypi", + "@octorelease/github", + "@octorelease/git" + ] +};