-
Notifications
You must be signed in to change notification settings - Fork 38
125 lines (109 loc) · 3.68 KB
/
release.yml
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
119
120
121
122
123
124
125
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'The type of version bump. Select "nobump" for no version change. See https://github.com/npm/node-semver#functions'
type: choice
required: true
default: nobump
options:
- major
- minor
- patch
- premajor
- preminor
- prepatch
- nobump # this action is custom for this action and does not exist in npm
jobs:
prepare:
if: github.repository_owner == 'viamrobotics'
runs-on: ubuntu-latest
container:
image: ghcr.io/viamrobotics/canon:amd64
outputs:
version: ${{ steps.which_version.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Build + Lint + Test
run: |
sudo chown -R testbot .
sudo -u testbot bash -lc 'make build lint test'
- name: Bump Version
shell: bash
run: npm version ${{ inputs.version }} --no-git-tag-version --preid "b"
if: inputs.version != 'nobump'
- name: Which Version
id: which_version
shell: bash
run: |
echo "version=$(npm pkg get version | sed 's/\"//g')" >> $GITHUB_OUTPUT
- name: Check if release exists
uses: cardinalby/[email protected]
id: release_exists
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
releaseName: v${{ steps.which_version.outputs.version }}
doNotFailIfNotFound: 'true'
- name: Cancelling - release already exists
uses: andymckay/[email protected]
if: steps.release_exists.outputs.id != ''
- name: Add + Commit
uses: EndBug/add-and-commit@v9
with:
new_branch: release/v${{ steps.which_version.outputs.version }}
message: Bump version to ${{ steps.which_version.outputs.version }}
- name: Open PR
run: |
sudo apt-get install -y gh
gh pr create -t "v${{ steps.which_version.outputs.version }}" -b "This is an auto-generated PR to merge the release branch back into main upon successful release" -B "main" -H "release/v${{ steps.which_version.outputs.version }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
needs: prepare
if: github.repository_owner == 'viamrobotics'
runs-on: ubuntu-latest
container:
image: ghcr.io/viamrobotics/canon:amd64
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: release/v${{ needs.prepare.outputs.version }}
- name: Build + Pack
run: |
sudo chown -R testbot .
sudo -u testbot bash -lc 'make build pack'
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: |
viamrobotics-sdk-*.tgz
docs/dist
release:
needs: [prepare, build]
if: github.repository_owner == 'viamrobotics'
runs-on: ubuntu-latest
container:
image: ghcr.io/viamrobotics/canon:amd64
steps:
- uses: actions/download-artifact@v4
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.prepare.outputs.version }}
files: dist/*.tgz
draft: true
prerelease: false
fail_on_unmatched_files: true
target_commitish: release/v${{ needs.prepare.outputs.version }}
- name: Publish Docs
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: dist/docs/dist
publish_branch: docs-gh_pages
cname: ts.viam.dev