Skip to content

Commit 2e53562

Browse files
author
Joli Lui
committed
separate workflow jobs
1 parent c57526d commit 2e53562

File tree

3 files changed

+105
-117
lines changed

3 files changed

+105
-117
lines changed

.github/workflows/release.yml

+10-117
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,22 @@
11
name: CLI Release
22

33
on:
4-
workflow_dispatch:
5-
# schedule:
6-
# - cron: '0 12 * * 2' # Runs every Tuesday at 12:00 PM (noon) ET
4+
push:
5+
tags:
6+
- '*'
77

88
jobs:
9-
10-
checks:
11-
runs-on: ubuntu-latest
12-
outputs:
13-
HAS_TAG: ${{ steps.check_tag.outputs.has_tag }}
14-
steps:
15-
- name: Check out code
16-
uses: actions/checkout@v3
17-
18-
- name: Check if commit has a new tag
19-
id: check_tag
20-
run: |
21-
if git describe --tags --exact-match HEAD >/dev/null 2>&1; then
22-
echo "has_tag=true" >> $GITHUB_OUTPUT
23-
echo true
24-
else
25-
echo "has_tag=false" >> $GITHUB_OUTPUT
26-
echo false
27-
fi
28-
299
release:
3010
runs-on: ubuntu-latest
31-
needs: checks
32-
outputs:
33-
CLI_VERSION: ${{ steps.get_cli_version.outputs.CLI_VERSION }}
34-
if: needs.checks.outputs.HAS_TAG == 'false'
35-
steps:
36-
- name: Check out code
37-
uses: actions/checkout@v3
38-
39-
- name: Set Git author
40-
run: |
41-
git config user.name 'github-actions[bot]'
42-
git config user.email 'github-actions[bot]@users.noreply.github.com'
43-
44-
- name: Get node version
45-
id: get_node_version
46-
run: |
47-
echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_OUTPUT
48-
49-
- name: Set up Node.js
50-
uses: actions/setup-node@v3
51-
with:
52-
node-version: "${{ steps.get_node_version.outputs.NVMRC }}"
53-
54-
- name: Install dependencies
55-
run: yarn install
56-
57-
- name: Build
58-
run: yarn build
59-
60-
- name: Bump CLI version
61-
run: npm version patch --force
62-
63-
- name: Read version from package.json
64-
id: get_cli_version
65-
run: echo "CLI_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
66-
67-
- name: Get latest tag
68-
id: get_latest_tag
69-
run: echo "LATEST_TAG=$(git describe --abbrev=0 --tags)" >> $GITHUB_OUTPUT
70-
71-
- name: Commit and push tag to main branch
72-
run: |
73-
git add .
74-
git commit --amend -m "Release v${{ steps.get_cli_version.outputs.CLI_VERSION }}"
75-
git tag -f ${{ steps.get_latest_tag.outputs.LATEST_TAG }}
76-
git push origin main --follow-tags
77-
11+
steps:
7812
- name: Create GitHub Release
79-
uses: ncipollo/release-action@v1
13+
uses: DevCycleHQ/release-action@main
8014
with:
81-
name: "v${{ steps.get_cli_version.outputs.CLI_VERSION }}"
82-
tag: "v${{ steps.get_cli_version.outputs.CLI_VERSION }}"
83-
generateReleaseNotes: "true"
84-
makeLatest: "true"
15+
draft: true
16+
prerelease: true
17+
github-token: ${{ secrets.GITHUB_TOKEN }}
8518

8619
- name: Publish to NPM
87-
run: npm publish --access public
88-
89-
update_doc:
90-
runs-on: ubuntu-latest
91-
permissions:
92-
contents: write
93-
pull-requests: write
94-
needs: release
95-
env:
96-
BRANCH_NAME: update-cli-version-to-v${{ needs.release.outputs.CLI_VERSION }}
97-
steps:
98-
- name: Check out code
99-
uses: actions/checkout@v2
100-
with:
101-
repository: DevCycleHQ/devcycle-docs
102-
# need access token
103-
token: ${{ secrets.PAT_TOKEN }}
104-
105-
- name: Set Git author
106-
run: |
107-
git config user.name 'github-actions[bot]'
108-
git config user.email 'github-actions[bot]@users.noreply.github.com'
109-
110-
- name: Update CLI version in docs repo
111-
run: |
112-
ls -al
113-
echo $BRANCH_NAME
114-
git checkout -b "$BRANCH_NAME"
115-
git branch
116-
sed -i 's/const DVC_CLI_VERSION = .*/const DVC_CLI_VERSION = '\''v${{ needs.release.outputs.CLI_VERSION }}'\'' \/\/ auto updated by dvc cli release workflow/' docusaurus.config.js
117-
git add docusaurus.config.js
118-
git commit -m "Update CLI version to v${{ needs.release.outputs.CLI_VERSION }}"
119-
120-
- name: Push code to docs repo
121-
run: |
122-
git push --set-upstream origin "$BRANCH_NAME"
123-
124-
- name: Create PR
12520
env:
126-
# need access token
127-
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
128-
run: gh pr create --repo DevCycleHQ/devcycle-docs --base main --head "$BRANCH_NAME" --title "Update CLI version to v${{ needs.release.outputs.CLI_VERSION }}" --body "This PR was automatically created by the DevCycle CLI release workflow."
129-
21+
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }}
22+
run: npm publish --access public

.github/workflows/tag.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Tag New Version
2+
3+
on:
4+
workflow_dispatch:
5+
# schedule:
6+
# - cron: '0 12 * * 2' # Runs every Tuesday at 12:00 PM (noon) ET
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
tag-new-version:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out code
15+
uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Get node version
20+
id: get_node_version
21+
run: |
22+
echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_OUTPUT
23+
24+
- name: Set up Node.js
25+
uses: actions/setup-node@v3
26+
with:
27+
node-version: "${{ steps.get_node_version.outputs.NVMRC }}"
28+
29+
- name: Install dependencies
30+
run: yarn install
31+
32+
- name: Build
33+
run: yarn build
34+
35+
- name: Bump CLI version
36+
run: npm version patch --force
37+
38+
- name: Get latest tag
39+
run: echo "LATEST_TAG=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV
40+
41+
- name: Commit and push tag to main branch
42+
run: |
43+
git add .
44+
git commit --amend -m "Release $LATEST_TAG"
45+
git tag -f $LATEST_TAG
46+
git push origin main --follow-tags

.github/workflows/update_doc.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Update Doc
2+
3+
on:
4+
workflow_run:
5+
workflows:
6+
- "CLI Release"
7+
types:
8+
- completed
9+
10+
jobs:
11+
update_doc:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
steps:
17+
- name: Check out code
18+
uses: actions/checkout@v3
19+
with:
20+
repository: DevCycleHQ/devcycle-docs
21+
# need to get/update access token
22+
token: ${{ secrets.PAT_TOKEN }}
23+
fetch-depth: 0
24+
25+
- name: Get latest tag
26+
id: get_latest_tag
27+
run: echo "LATEST_TAG=$(git describe --abbrev=0 --tags)" >> $GITHUB_OUTPUT
28+
29+
- name: Update CLI version in docs repo
30+
env:
31+
CLI_VERSION: v${{ steps.get_latest_tag.outputs.LATEST_TAG }}
32+
BRANCH_NAME: update-cli-version-to-${{ env.CLI_VERSION }}
33+
run: |
34+
git checkout -b "$BRANCH_NAME"
35+
sed -i 's/const DVC_CLI_VERSION = .*/const DVC_CLI_VERSION = '\''$CLI_VERSION'\'' \/\/ auto updated by dvc cli release workflow/' docusaurus.config.js
36+
git add docusaurus.config.js
37+
git commit -m "Update CLI version to $CLI_VERSION"
38+
39+
- name: Push code to docs repo
40+
run: |
41+
git push --set-upstream origin "$BRANCH_NAME"
42+
43+
- name: Create PR
44+
env:
45+
# need to get/update access token
46+
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
47+
CLI_VERSION: v${{ steps.get_latest_tag.outputs.LATEST_TAG }}
48+
BRANCH_NAME: update-cli-version-to-${{ env.CLI_VERSION }}
49+
run: gh pr create --repo DevCycleHQ/devcycle-docs --base main --head "$BRANCH_NAME" --title "Update CLI version to $CLI_VERSION" --body "This PR was automatically created by the DevCycle CLI release workflow."

0 commit comments

Comments
 (0)