Skip to content

Commit d7b6ce3

Browse files
authored
feat: converted circleci build job to gha workflow (#2719)
1 parent 1c36ecc commit d7b6ce3

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed

.github/workflows/build.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: stoplightio/prism/build
2+
on:
3+
push:
4+
branches:
5+
- master
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
container:
10+
image: node:18.20
11+
steps:
12+
- uses: actions/[email protected]
13+
- name: restore_cache
14+
uses: actions/[email protected]
15+
with:
16+
key: yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }}
17+
path: node_modules/
18+
restore-keys: yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }}
19+
- name: Install Dependencies
20+
run: yarn --frozen-lockfile
21+
- name: Lint the codebase
22+
run: yarn lint
23+
- name: Run tests
24+
run: yarn test --colors --maxWorkers=2
25+
- name: Run build
26+
run: yarn build
27+
harness-macos:
28+
if: (github.ref == 'refs/tags/"v[0-9].[0-9]+.[0-9]+"') && (github.ref != 'refs/heads/master')
29+
runs-on: macos-latest
30+
env:
31+
executor: macos
32+
install_manually: true
33+
steps:
34+
- uses: maxim-lobanov/[email protected]
35+
with:
36+
xcode-version: 13.4.1
37+
- uses: actions/[email protected]
38+
- run: nvm install 18.20.1 && nvm alias default 18.20.1
39+
if: env.install_manually
40+
- run: pip3 install pipenv gunicorn
41+
if: env.install_manually
42+
- run: sudo bash -c 'echo "0.0.0.0 httpbin.org" >> /etc/hosts'
43+
if: env.install_manually
44+
- run: git clone https://github.com/stoplightio/httpbin httpbin
45+
if: env.install_manually
46+
- run: cd httpbin && pip3 install --no-cache-dir -r <(pipenv requirements) && pip3 install --no-cache-dir ./
47+
if: env.install_manually
48+
- run: cd httpbin && gunicorn -b 0.0.0.0:80 httpbin:app -k gevent
49+
if: env.install_manually
50+
- name: Install Dependencies
51+
run: yarn --frozen-lockfile
52+
- name: Create CLI binary
53+
run: yarn build.binary
54+
- name: Run Harness
55+
run: yarn test.harness
56+
harness-docker:
57+
runs-on: ubuntu-latest
58+
container:
59+
image: node:18.20
60+
env:
61+
executor: docker-harness
62+
install_manually: true
63+
steps:
64+
- uses: actions/[email protected]
65+
- run: nvm install 18.20.1 && nvm alias default 18.20.1
66+
if: env.install_manually
67+
- run: pip3 install pipenv gunicorn
68+
if: env.install_manually
69+
- run: sudo bash -c 'echo "0.0.0.0 httpbin.org" >> /etc/hosts'
70+
if: env.install_manually
71+
- run: git clone REDACTED://github.com/stoplightio/httpbin httpbin
72+
if: env.install_manually
73+
- run: cd httpbin && pip3 install --no-cache-dir -r <(pipenv requirements) && pip3 install --no-cache-dir ./
74+
if: env.install_manually
75+
- run: cd httpbin && gunicorn -b 0.0.0.0:80 httpbin:app -k gevent
76+
if: env.install_manually
77+
- name: Install Dependencies
78+
run: yarn --frozen-lockfile
79+
- name: Create CLI binary
80+
run: yarn build.binary
81+
- name: Run Harness
82+
run: yarn test.harness
83+
publish:
84+
if: (github.ref == 'refs/tags/"v[0-9].[0-9]+.[0-9]+"') && (github.ref != 'refs/heads/master')
85+
runs-on: ubuntu-latest
86+
container:
87+
image: node:18.20
88+
needs:
89+
- build
90+
- harness-macos
91+
- harness-docker
92+
steps:
93+
- uses: actions/[email protected]
94+
- name: Set git identity
95+
run: git config user.email "[email protected]" && git config user.name "circleci"
96+
- name: Install Dependencies
97+
run: yarn --frozen-lockfile
98+
- name: Build all code to JavaScript
99+
run: yarn build
100+
- run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
101+
- name: Publish
102+
run: yarn lerna publish from-git --create-release=github --yes
103+
- name: Create CLI binaries
104+
run: npx pkg --out-path ./cli-binaries ./packages/cli/
105+
- uses: actions/[email protected]
106+
with:
107+
path: "./cli-binaries"
108+
- uses: actions/[email protected]
109+
with:
110+
path: ".//cli-binaries"
111+
upload_artifacts:
112+
if: (github.ref == 'refs/tags/"v[0-9].[0-9]+.[0-9]+"') && (github.ref != 'refs/heads/master')
113+
runs-on: ubuntu-latest
114+
container:
115+
image: golang:1.23
116+
needs:
117+
- publish
118+
steps:
119+
- uses: actions/[email protected]
120+
with:
121+
path: "/tmp/"
122+
- name: Download GitHub Release Utility
123+
run: go install github.com/tcnksm/ghr@latest
124+
- name: Publish Release artifacts on GitHub
125+
run: ghr -t ${{github.token}} -u ${{ github.actor }} -r ${{ github.repository }} -c ${{ github.sha }} ${{ github.ref }} /tmp/cli-binaries

0 commit comments

Comments
 (0)