Skip to content

Commit 95b2361

Browse files
committed
Add: build check in pr gates
1 parent 8ac7a31 commit 95b2361

5 files changed

Lines changed: 148 additions & 39 deletions

File tree

.github/workflows/auto-version-and-publish.yml

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -59,45 +59,12 @@ jobs:
5959
6060
# Build all packages
6161
build:
62-
runs-on: ubuntu-latest
62+
needs: changes
63+
uses: ./.github/workflows/build.yml
64+
with:
65+
upload_artifacts: true
6366
permissions:
6467
contents: read
65-
needs: changes
66-
steps:
67-
- uses: actions/checkout@v4
68-
69-
- name: Setup Node.js
70-
uses: actions/setup-node@v4
71-
with:
72-
node-version: '20'
73-
cache: 'npm'
74-
75-
- name: Install dependencies
76-
run: npm ci
77-
78-
- name: Run linting
79-
run: npm run lint
80-
81-
- name: Build packages
82-
run: |
83-
npm run clean
84-
npm run build
85-
86-
# TODO: Add tests
87-
# - name: Run tests
88-
# run: npm test
89-
90-
- name: Upload SDK artifacts
91-
uses: actions/upload-artifact@v4
92-
with:
93-
name: sdk-dist
94-
path: dist/
95-
96-
- name: Upload CLI artifacts
97-
uses: actions/upload-artifact@v4
98-
with:
99-
name: cli-dist
100-
path: packages/cli/dist/
10168

10269
# Version and publish SDK
10370
publish-sdk:

.github/workflows/build.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
upload_artifacts:
7+
required: false
8+
type: boolean
9+
default: false
10+
description: 'Whether to upload build artifacts'
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
cache: 'npm'
23+
24+
- name: Install dependencies
25+
run: npm ci
26+
27+
- name: Run linting
28+
run: npm run lint
29+
30+
- name: Build packages
31+
run: |
32+
npm run clean
33+
npm run build
34+
35+
# TODO: Add tests when available
36+
# - name: Run tests
37+
# run: npm test
38+
39+
- name: Upload SDK artifacts
40+
if: inputs.upload_artifacts
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: sdk-dist
44+
path: dist/
45+
46+
- name: Upload CLI artifacts
47+
if: inputs.upload_artifacts
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: cli-dist
51+
path: packages/cli/dist/

.github/workflows/pr-checks.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: PR Checks
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
pull-requests: write
11+
12+
jobs:
13+
# Detect changes to determine what needs to be checked
14+
changes:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
cli: ${{ steps.filter.outputs.cli }}
18+
sdk: ${{ steps.filter.outputs.sdk }}
19+
workflows: ${{ steps.filter.outputs.workflows }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v3.0.1
24+
id: filter
25+
with:
26+
filters: |
27+
cli:
28+
- 'packages/cli/src/**'
29+
- 'packages/cli/package.json'
30+
- 'packages/cli/tsconfig.json'
31+
sdk:
32+
- 'src/**'
33+
- 'package.json'
34+
- 'tsconfig.json'
35+
workflows:
36+
- '.github/workflows/**'
37+
38+
# Build and test
39+
build:
40+
needs: changes
41+
uses: ./.github/workflows/build.yml
42+
with:
43+
upload_artifacts: false
44+
permissions:
45+
contents: read
46+
47+
# Check versions to ensure they will publish correctly
48+
version-check:
49+
runs-on: ubuntu-latest
50+
needs: changes
51+
if: needs.changes.outputs.sdk == 'true' || needs.changes.outputs.cli == 'true'
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- name: Setup Node.js
56+
uses: actions/setup-node@v4
57+
with:
58+
node-version: '20'
59+
registry-url: 'https://npm.pkg.github.com'
60+
61+
- name: Check SDK version
62+
if: needs.changes.outputs.sdk == 'true'
63+
run: |
64+
CURRENT_VERSION=$(node -p "require('./package.json').version")
65+
echo "SDK version: $CURRENT_VERSION"
66+
67+
# Check if version already exists
68+
if npm view @uipath/uipath-typescript@$CURRENT_VERSION version 2>/dev/null; then
69+
echo "::warning::SDK version $CURRENT_VERSION already exists. Version bump will be required on merge."
70+
else
71+
echo "✅ SDK version $CURRENT_VERSION is available for publishing"
72+
fi
73+
env:
74+
GH_NPM_REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
76+
- name: Check CLI version
77+
if: needs.changes.outputs.cli == 'true'
78+
working-directory: packages/cli
79+
run: |
80+
CURRENT_VERSION=$(node -p "require('./package.json').version")
81+
echo "CLI version: $CURRENT_VERSION"
82+
83+
# Check if version already exists
84+
if npm view @uipath/cli@$CURRENT_VERSION version 2>/dev/null; then
85+
echo "::warning::CLI version $CURRENT_VERSION already exists. Version bump will be required on merge."
86+
else
87+
echo "✅ CLI version $CURRENT_VERSION is available for publishing"
88+
fi
89+
env:
90+
GH_NPM_REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"README.md"
1919
],
2020
"scripts": {
21-
"clean": "rm -rf dist && npm run clean --workspaces",
21+
"clean": "rimraf dist && npm run clean --workspaces",
2222
"prebuild": "npm run clean",
2323
"build": "tsc && npm run build --workspaces",
2424
"build:sdk": "tsc",
@@ -58,6 +58,7 @@
5858
"dotenv": "^17.2.0",
5959
"eslint": "^8.57.1",
6060
"jest": "^29.7.0",
61+
"rimraf": "^6.0.1",
6162
"ts-jest": "^29.4.0",
6263
"typescript": "^5.3.3"
6364
},

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"README.md"
1515
],
1616
"scripts": {
17-
"clean": "rm -rf dist tsconfig.tsbuildinfo",
17+
"clean": "rimraf dist tsconfig.tsbuildinfo",
1818
"prebuild": "npm run clean",
1919
"build": "tsc --build --force",
2020
"prepack": "npm run build",

0 commit comments

Comments
 (0)