|
1 | 1 | name: CLI Release
|
2 | 2 |
|
3 | 3 | 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 | + - '*' |
7 | 7 |
|
8 | 8 | 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 |
| -
|
29 | 9 | release:
|
30 | 10 | 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: |
78 | 12 | - name: Create GitHub Release
|
79 |
| - uses: ncipollo/release-action@v1 |
| 13 | + uses: DevCycleHQ/release-action@main |
80 | 14 | 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 }} |
85 | 18 |
|
86 | 19 | - 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 |
125 | 20 | 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 |
0 commit comments