-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add release yaml #219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
L-Joli
merged 3 commits into
main
from
DVC-8098-create-github-action-to-automate-releasing-the-cli
Jul 14, 2023
+182
−0
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| name: GitHub release and Publish to NPM | ||
| description: Create a GitHub release and publish to NPM | ||
|
|
||
| inputs: | ||
| github-token: | ||
| required: true | ||
| description: 'The GitHub token to use for authentication' | ||
| release-tag: | ||
| required: true | ||
| description: 'The tag to use for the release' | ||
| draft: | ||
| required: false | ||
| description: 'Whether to create a draft (unpublished) release' | ||
| default: 'true' | ||
| prerelease: | ||
| required: false | ||
| description: 'Whether to create a prerelease release' | ||
| default: 'true' | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| # Replace with DevCycleHQ/release-action/gh-release@main when it's ready | ||
| - name: Create GitHub Release | ||
| uses: ncipollo/release-action@v1 | ||
| with: | ||
| name: "${{ inputs.release-tag }}" | ||
| tag: "${{ inputs.release-tag }}" | ||
| generateReleaseNotes: "true" | ||
| makeLatest: "true" | ||
| token: ${{ inputs.github-token }} | ||
| draft: ${{ inputs.draft }} | ||
| prerelease: ${{ inputs.prerelease }} | ||
|
|
||
| - name: Publish to NPM | ||
| shell: bash | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }} | ||
| run: npm publish --access public |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| name: Update Doc | ||
|
|
||
| description: 'Update the CLI version in devcycle-docs' | ||
|
|
||
| inputs: | ||
| latest_tag: | ||
| required: true | ||
| description: 'The latest tag from the workflow that uses this action' | ||
| access_token: | ||
| required: true | ||
| description: 'The access token to use for authentication' | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Check out code | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| repository: DevCycleHQ/devcycle-docs | ||
| path: devcycle-docs | ||
| token: ${{ inputs.access_token }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set Git author | ||
| shell: bash | ||
| working-directory: devcycle-docs | ||
| run: | | ||
| git config --global user.email "github-tracker-bot@taplytics.com" | ||
| git config --global user.name "DevCycle Automation" | ||
|
|
||
| - name: Set branch name | ||
| shell: bash | ||
| working-directory: devcycle-docs | ||
| run: echo "BRANCH_NAME=update-cli-version-to-${{ inputs.latest_tag }}" >> $GITHUB_ENV | ||
|
|
||
| - name: Update CLI version in docs repo | ||
| shell: bash | ||
| working-directory: devcycle-docs | ||
| run: | | ||
| git checkout -b "$BRANCH_NAME" | ||
| sed -i "s/const DVC_CLI_VERSION = .*/const DVC_CLI_VERSION = '${{ inputs.latest_tag }}' \/\/ auto updated by dvc cli release workflow/" docusaurus.config.js | ||
| git add docusaurus.config.js | ||
| git commit -m "Update CLI version to ${{ inputs.latest_tag }}" | ||
|
|
||
| - name: Push code to docs repo | ||
| shell: bash | ||
| working-directory: devcycle-docs | ||
| run: git push --set-upstream origin "$BRANCH_NAME" | ||
|
|
||
| - name: Create PR | ||
| shell: bash | ||
| working-directory: devcycle-docs | ||
| env: | ||
| GH_TOKEN: ${{ inputs.access_token }} | ||
| run: gh pr create --repo DevCycleHQ/devcycle-docs --base main --head "$BRANCH_NAME" --title "Update CLI version to $LATEST_TAG" --body "This PR was automatically created by the DevCycle CLI release workflow." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| name: CLI Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| draft-release: | ||
| description: 'Draft release?' | ||
| required: false | ||
| type: boolean | ||
| default: true | ||
| prerelease: | ||
| description: 'Prerelease?' | ||
| required: false | ||
| type: boolean | ||
| default: true | ||
| npm-version: | ||
| description: 'NPM version bump?' | ||
| required: false | ||
| type: choice | ||
| options: | ||
| - major | ||
| - minor | ||
| - patch | ||
| default: 'patch' | ||
|
|
||
| # schedule: | ||
| # - cron: '0 12 * * 2' # Runs every Tuesday at 12:00 PM (noon) ET | ||
rob-odwyer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| cli-release: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check out code | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| fetch-depth: 0 | ||
L-Joli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| token: ${{ secrets.AUTOMATION_USER_TOKEN }} | ||
|
|
||
| - name: Set Git author | ||
| run: | | ||
| git config --global user.email "github-tracker-bot@taplytics.com" | ||
| git config --global user.name "DevCycle Automation" | ||
|
|
||
| - name: Get node version | ||
| id: get_node_version | ||
| run: | | ||
| echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v3 | ||
| with: | ||
| node-version: "${{ steps.get_node_version.outputs.NVMRC }}" | ||
|
|
||
| - name: Install dependencies | ||
| run: yarn install | ||
|
|
||
| - name: Build | ||
| run: yarn build | ||
|
|
||
| - name: Bump CLI version | ||
| run: npm version ${{ inputs.npm-version }} --force | ||
|
|
||
| - name: Get latest tag | ||
| run: echo "LATEST_TAG=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV | ||
|
|
||
| - name: Commit and push tag to main branch | ||
| run: | | ||
L-Joli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| git add . | ||
| git commit --amend -m "Release $LATEST_TAG" | ||
rob-odwyer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| git tag -f $LATEST_TAG | ||
| git push --atomic origin main $LATEST_TAG | ||
|
|
||
| - name: Release | ||
| uses: ./.github/actions/release | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| # cannot read $LATEST_TAG here so using ${{ env.LATEST_TAG }} | ||
| release-tag: ${{ env.LATEST_TAG }} | ||
| draft: ${{ inputs.draft-release }} | ||
| prerelease: ${{ inputs.prerelease }} | ||
|
|
||
| - name: Update Doc | ||
| uses: ./.github/actions/update-doc | ||
| with: | ||
| latest_tag: $LATEST_TAG | ||
| access_token: ${{ secrets.AUTOMATION_USER_TOKEN }} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.