Skip to content

Commit 7b43431

Browse files
author
Joli Lui
committed
create composite actions
1 parent a9d58ce commit 7b43431

File tree

6 files changed

+182
-117
lines changed

6 files changed

+182
-117
lines changed

.github/actions/release/action.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: GitHub release and Publish to NPM
2+
description: Create a GitHub release and publish to NPM
3+
4+
inputs:
5+
github-token:
6+
required: true
7+
description: 'The GitHub token to use for authentication'
8+
release-tag:
9+
required: true
10+
description: 'The tag to use for the release'
11+
draft:
12+
required: false
13+
description: 'Whether to create a draft (unpublished) release'
14+
default: 'true'
15+
prerelease:
16+
required: false
17+
description: 'Whether to create a prerelease release'
18+
default: 'true'
19+
20+
runs:
21+
using: 'composite'
22+
steps:
23+
# Replace with DevCycleHQ/release-action/gh-release@main when it's ready
24+
- name: Create GitHub Release
25+
uses: ncipollo/release-action@v1
26+
with:
27+
name: "${{ inputs.release-tag }}"
28+
tag: "${{ inputs.release-tag }}"
29+
generateReleaseNotes: "true"
30+
makeLatest: "true"
31+
token: ${{ inputs.github-token }}
32+
draft: ${{ inputs.draft }}
33+
prerelease: ${{ inputs.prerelease }}
34+
35+
- name: Publish to NPM
36+
shell: bash
37+
env:
38+
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }}
39+
run: npm publish --access public

.github/actions/update-doc/action.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Update Doc
2+
3+
description: 'Update the CLI version in devcycle-docs'
4+
5+
inputs:
6+
latest_tag:
7+
required: true
8+
description: 'The latest tag from the workflow that uses this action'
9+
access_token:
10+
required: true
11+
description: 'The access token to use for authentication'
12+
13+
runs:
14+
using: 'composite'
15+
steps:
16+
- name: Check out code
17+
uses: actions/checkout@v3
18+
with:
19+
repository: DevCycleHQ/devcycle-docs
20+
path: devcycle-docs
21+
token: ${{ inputs.access_token }}
22+
fetch-depth: 0
23+
24+
- name: Set Git author
25+
shell: bash
26+
working-directory: devcycle-docs
27+
run: |
28+
git config --global user.email "[email protected]"
29+
git config --global user.name "DevCycle Automation"
30+
31+
- name: Set branch name
32+
shell: bash
33+
working-directory: devcycle-docs
34+
run: echo "BRANCH_NAME=update-cli-version-to-${{ inputs.latest_tag }}" >> $GITHUB_ENV
35+
36+
- name: Update CLI version in docs repo
37+
shell: bash
38+
working-directory: devcycle-docs
39+
run: |
40+
git checkout -b "$BRANCH_NAME"
41+
sed -i "s/const DVC_CLI_VERSION = .*/const DVC_CLI_VERSION = '${{ inputs.latest_tag }}' \/\/ auto updated by dvc cli release workflow/" docusaurus.config.js
42+
git add docusaurus.config.js
43+
git commit -m "Update CLI version to ${{ inputs.latest_tag }}"
44+
45+
- name: Push code to docs repo
46+
shell: bash
47+
working-directory: devcycle-docs
48+
run: git push --set-upstream origin "$BRANCH_NAME"
49+
50+
- name: Create PR
51+
shell: bash
52+
working-directory: devcycle-docs
53+
env:
54+
GH_TOKEN: ${{ inputs.access_token }}
55+
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."

.github/workflows/cli-release.yml

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: CLI Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
draft-release:
7+
description: 'Draft release?'
8+
required: false
9+
type: boolean
10+
default: true
11+
prerelease:
12+
description: 'Prerelease?'
13+
required: false
14+
type: boolean
15+
default: true
16+
npm-version:
17+
description: 'NPM version bump?'
18+
required: false
19+
type: choice
20+
options:
21+
- major
22+
- minor
23+
- patch
24+
default: 'patch'
25+
26+
# schedule:
27+
# - cron: '0 12 * * 2' # Runs every Tuesday at 12:00 PM (noon) ET
28+
permissions:
29+
contents: write
30+
31+
jobs:
32+
cli-release:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Check out code
36+
uses: actions/checkout@v3
37+
with:
38+
fetch-depth: 0
39+
token: ${{ secrets.AUTOMATION_USER_TOKEN }}
40+
41+
- name: Set Git author
42+
run: |
43+
git config --global user.email "[email protected]"
44+
git config --global user.name "DevCycle Automation"
45+
46+
- name: Get node version
47+
id: get_node_version
48+
run: |
49+
echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_OUTPUT
50+
51+
- name: Set up Node.js
52+
uses: actions/setup-node@v3
53+
with:
54+
node-version: "${{ steps.get_node_version.outputs.NVMRC }}"
55+
56+
- name: Install dependencies
57+
run: yarn install
58+
59+
- name: Build
60+
run: yarn build
61+
62+
- name: Bump CLI version
63+
run: npm version ${{ inputs.npm-version }} --force
64+
65+
- name: Get latest tag
66+
run: echo "LATEST_TAG=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV
67+
68+
- name: Commit and push tag to main branch
69+
run: |
70+
git add .
71+
git commit --amend -m "Release $LATEST_TAG"
72+
git tag -f $LATEST_TAG
73+
git push --atomic origin main $LATEST_TAG
74+
75+
- name: Release
76+
uses: ./.github/actions/release
77+
with:
78+
github-token: ${{ secrets.GITHUB_TOKEN }}
79+
# cannot read $LATEST_TAG here so using ${{ env.LATEST_TAG }}
80+
release-tag: ${{ env.LATEST_TAG }}
81+
draft: ${{ inputs.draft-release }}
82+
prerelease: ${{ inputs.prerelease }}
83+
84+
- name: Update Doc
85+
uses: ./.github/actions/update-doc
86+
with:
87+
latest_tag: $LATEST_TAG
88+
access_token: ${{ secrets.AUTOMATION_USER_TOKEN }}

.github/workflows/release.yml

-22
This file was deleted.

.github/workflows/tag.yml

-46
This file was deleted.

.github/workflows/update_doc.yml

-49
This file was deleted.

0 commit comments

Comments
 (0)