-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add release yaml
- Loading branch information
Showing
3 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 "[email protected]" | ||
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 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 | ||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
cli-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ secrets.AUTOMATION_USER_TOKEN }} | ||
|
||
- name: Set Git author | ||
run: | | ||
git config --global user.email "[email protected]" | ||
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: | | ||
git add . | ||
git commit --amend -m "Release $LATEST_TAG" | ||
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 }} |