diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0d57713e0..fb36c928b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,28 +2,30 @@ name: Release on: workflow_dispatch: + inputs: + version: + description: 'The type of version bump. Select "nobump" for no version change. See https://github.com/npm/node-semver#functions' + type: choice + required: true + default: nobump + options: + - major + - minor + - patch + - premajor + - preminor + - prepatch + - nobump # this action is custom for this action and does not exist in npm jobs: prepare: - if: github.repository_owner == 'viamrobotics' && startsWith(github.ref_name, 'rc-') + if: github.repository_owner == 'viamrobotics' runs-on: ubuntu-latest container: image: ghcr.io/viamrobotics/canon:amd64 outputs: version: ${{ steps.which_version.outputs.version }} steps: - - name: Check if organization member - id: is_organization_member - uses: jamessingleton/is-organization-member@1.0.1 - with: - organization: viamrobotics - username: ${{ github.actor }} - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Cancelling - not an organization member - uses: andymckay/cancel-action@0.2 - if: steps.is_organization_member.outputs.result == 'false' - - name: Checkout Code uses: actions/checkout@v4 @@ -34,7 +36,8 @@ jobs: - name: Bump Version shell: bash - run: npm version $(npm pkg get version | sed -e 's/\"//g' -e 's/-rc.*//g') --no-git-tag-version + run: npm version ${{ inputs.version }} --no-git-tag-version + if: inputs.version != 'nobump' - name: Which Version id: which_version @@ -58,19 +61,18 @@ jobs: - name: Add + Commit uses: EndBug/add-and-commit@v9 with: - new_branch: rc-${{ steps.which_version.outputs.version }} + new_branch: release/v${{ steps.which_version.outputs.version }} message: Bump version to ${{ steps.which_version.outputs.version }} - name: Open PR - uses: repo-sync/pull-request@v2 - with: - destination_branch: 'main' - pr_title: ${{ steps.which_version.outputs.version }} - pr_body: This is an auto-generated PR to merge the rc branch back into main upon successful release. + run: | + gh pr create -t "v${{ steps.which_version.outputs.version }}" -b "This is an auto-generated PR to merge the release branch back into main upon successful release" -B "main" -H "release/v${{ steps.which_version.outputs.version }}" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} build: needs: prepare - if: github.repository_owner == 'viamrobotics' && startsWith(github.ref_name, 'rc-') + if: github.repository_owner == 'viamrobotics' runs-on: ubuntu-latest container: image: ghcr.io/viamrobotics/canon:amd64 @@ -78,7 +80,7 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - ref: rc-${{ needs.prepare.outputs.version }} + ref: release/v${{ needs.prepare.outputs.version }} - name: Build + Pack run: | @@ -95,7 +97,7 @@ jobs: release: needs: [prepare, build] - if: github.repository_owner == 'viamrobotics' && startsWith(github.ref_name, 'rc-') + if: github.repository_owner == 'viamrobotics' runs-on: ubuntu-latest container: image: ghcr.io/viamrobotics/canon:amd64 @@ -111,7 +113,7 @@ jobs: draft: true prerelease: false fail_on_unmatched_files: true - target_commitish: rc-${{ needs.prepare.outputs.version }} + target_commitish: release/v${{ needs.prepare.outputs.version }} - name: Publish Docs uses: peaceiris/actions-gh-pages@v3 diff --git a/.github/workflows/release_candidate.yml b/.github/workflows/release_candidate.yml deleted file mode 100644 index 13bb765b9..000000000 --- a/.github/workflows/release_candidate.yml +++ /dev/null @@ -1,151 +0,0 @@ -name: Release Candidate - -on: - workflow_dispatch: - inputs: - version: - description: 'The type of version bump. Select "nobump" for no version change. `rc` version bumps will happen automatically, so select the type of version bump for the final release. See https://github.com/npm/node-semver#functions' - type: choice - required: true - default: nobump - options: - - premajor - - preminor - - prepatch - - nobump # this action is custom for this action and does not exist in npm - secrets: - NPM_TOKEN: - required: true - -jobs: - prepare: - if: github.repository_owner == 'viamrobotics' - runs-on: ubuntu-latest - container: - image: ghcr.io/viamrobotics/canon:amd64 - outputs: - rc_version: ${{ steps.which_version.outputs.rc_version }} - version: ${{ steps.which_version.outputs.version }} - steps: - - name: Check if organization member - id: is_organization_member - uses: jamessingleton/is-organization-member@1.0.1 - with: - organization: viamrobotics - username: ${{ github.actor }} - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Cancelling - not an organization member - uses: andymckay/cancel-action@0.2 - if: steps.is_organization_member.outputs.result == 'false' - - - name: Install GH CLI - run: | - type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y) - curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ - && sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ - && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ - && sudo apt update \ - && sudo apt install gh -y - - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Build + Lint + Test - run: | - sudo chown -R testbot . - sudo -u testbot bash -lc 'make build lint test' - - - name: Current version - id: current_version - shell: bash - run: | - echo "current_version=$(npm pkg get version)" >> $GITHUB_OUTPUT - - - name: Bump Version - id: bump_version - shell: bash - run: | - if ${{ contains(steps.current_version.outputs.current_version, 'rc') }} ; then - npm version prerelease --preid=rc --no-git-tag-version - elif ${{ contains(steps.current_version.outputs.current_version, 'next') && inputs.version == 'prepatch' }} ; then - npm version prerelease --preid=rc --no-git-tag-version - else - npm version ${{ inputs.version }} --preid=rc --no-git-tag-version - fi - if: inputs.version != 'nobump' - - - name: Which Version - id: which_version - shell: bash - run: | - echo "rc_version=$(npm pkg get version | sed 's/\"//g')" >> $GITHUB_OUTPUT - echo "version=$(npm pkg get version | sed -e 's/\"//g' -e 's/-rc.*//g')" >> $GITHUB_OUTPUT - - - name: Check if release exists - uses: cardinalby/git-get-release-action@1.2.4 - id: release_exists - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - releaseName: v${{ steps.which_version.outputs.rc_version }} - doNotFailIfNotFound: 'true' - - - name: Cancelling - release already exists - uses: andymckay/cancel-action@0.2 - if: steps.release_exists.outputs.id != '' - - - name: Add + Commit - uses: EndBug/add-and-commit@v9 - with: - new_branch: rc-${{ steps.which_version.outputs.version }} - message: Bump version to ${{ steps.which_version.outputs.rc_version }} - - - name: Open PR - run: | - gh pr create -t "rc-${{ steps.which_version.outputs.version }}" -b "This is an auto-generated PR to merge the RC branch back into main upon successful release" -B "main" -H "rc-${{ steps.which_version.outputs.version }}" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - build: - needs: prepare - if: github.repository_owner == 'viamrobotics' - runs-on: ubuntu-latest - container: - image: ghcr.io/viamrobotics/canon:amd64 - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - ref: rc-${{ needs.prepare.outputs.version }} - - - name: Build + Pack - run: | - sudo chown -R testbot . - sudo -u testbot bash -lc 'make build pack' - - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: dist - path: viamrobotics-sdk-*.tgz - - release: - needs: [prepare, build] - if: github.repository_owner == 'viamrobotics' - runs-on: ubuntu-latest - container: - image: ghcr.io/viamrobotics/canon:amd64 - - steps: - - uses: actions/download-artifact@v3 - - - name: Release - uses: softprops/action-gh-release@v1 - with: - tag_name: v${{ needs.prepare.outputs.rc_version }} - files: dist/* - draft: true - prerelease: true - fail_on_unmatched_files: true - target_commitish: rc-${{ needs.prepare.outputs.version }}