Repository navigation
118 lines (109 loc) · 3.35 KB
/
Copy pathrelease-cli.yml
File metadata and controls
118 lines (109 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Release CLI
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
NODE_VERSION: '20'
jobs:
determine-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.VERSION }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Get version
id: get_version
run: |
# version format is 1.2.3
PREV_VERSION=$(git describe --tags --abbrev=0 --match "v*" | sed 's/^v//')
# bump the middle number
MIDDLE_NUMBER=$(echo $PREV_VERSION | cut -d. -f2)
MIDDLE_NUMBER=$((MIDDLE_NUMBER+1))
VERSION=$(echo $PREV_VERSION | cut -d. -f1).$(echo $MIDDLE_NUMBER).$(echo $PREV_VERSION | cut -d. -f3)
echo "New version: $VERSION"
# emit as an output
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
create-release:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
needs:
- determine-version
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.determine-version.outputs.version }}
release_name: Release v${{ needs.determine-version.outputs.version }}
draft: false
prerelease: false
release-js-cli:
runs-on: ubuntu-latest
needs:
- create-release
- determine-version
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm install
- run: mkdir -p dist
- name: Pack the CLI with @vercel/ncc
run: npx @vercel/ncc build ./packages/cli/qkube -o ./dist/js
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./dist/js/index.js
asset_name: qkube-v${{ needs.determine-version.outputs.version }}.js
asset_content_type: application/javascript
release-npm:
runs-on: ubuntu-latest
needs:
- determine-version
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm install
- name: Update package.json version
working-directory: ./packages/cli
run: |
content=$(cat package.json)
updated_content=$(echo "$content" | jq --arg new_version "${{ needs.determine-version.outputs.version }}" '.version = $new_version')
echo "$updated_content" > package.json
- name: Login to NPM
run: npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_PUBLISH_TOKEN }}
- name: Publish
uses: nick-fields/retry@v3
with:
max_attempts: 3
timeout_minutes: 5
command: |
set -o pipefail
cd ./packages/cli
npm pack
npm publish --access public --verbose