-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (154 loc) · 5.5 KB
/
nodejs.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Test, Build & Publish
on:
create:
tags: '**'
push:
branches: '**'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: setup pnpm
run: |
npm i -g pnpm
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: npm install, build
run: |
pnpm install
./node_modules/.bin/tsc
env:
CI: true
- name: Run test component
run: mv test-folders/component-tests tests && ./node_modules/.bin/ember test
- name: Run test helpers
run: rm -rf tests && mv test-folders/helper-tests tests && ./node_modules/.bin/ember test
- name: Run test modifiers
run: rm -rf tests && mv test-folders/modifier-tests tests && ./node_modules/.bin/ember test
- name: Run tests mixed
run: rm -rf tests && mv test-folders/mixed-tests tests && ./node_modules/.bin/ember test
ember-try:
name: ember-try (${{ matrix.scenario }})
needs: test
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
env:
CI: 'true'
strategy:
fail-fast: false
matrix:
experimental: [false]
scenario:
- release
include:
- scenario: beta
experimental: true
- scenario: canary
experimental: true
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: setup pnpm
run: |
npm i -g pnpm
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: npm install, build
run: |
pnpm install
./node_modules/.bin/tsc
- name: Setup ember-try scenario
run: ./node_modules/.bin/ember try:one ember-${{ matrix.scenario }} --skip-cleanup --- cat package.json
- name: Run test component
run: mv test-folders/component-tests tests && ./node_modules/.bin/ember test
- name: Run test helpers
run: rm -rf tests && mv test-folders/helper-tests tests && ./node_modules/.bin/ember test
- name: Run test modifiers
run: rm -rf tests && mv test-folders/modifier-tests tests && ./node_modules/.bin/ember test
- name: Run tests mixed
run: rm -rf tests && mv test-folders/mixed-tests tests && ./node_modules/.bin/ember test
deploy:
needs: [test, ember-try]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: npm install, build, and deploy docs
run: |
mkdir ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
npm install
./node_modules/.bin/tsc
env:
CI: true
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
- name: deploy npm
if: github.ref == 'refs/heads/main'
run: |
version=$(cat package.json | jq -r '.version')
TAG=v$version
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "tag exists";
else
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
npm publish || echo "already published"
fi
env:
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
- name: create tag
if: github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_COMMIT: ${{ github.sha }}
run: |
version=$(cat package.json | jq -r '.version')
TAG=v$version
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "tag exists";
else
curl -X POST -H "Content-Type: application/json" -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/patricklx/ember-hbs-imports/git/refs -d "{ \"ref\": \"refs/tags/$TAG\", \"sha\": \"$GITHUB_COMMIT\" }"
fi
- name: Create a Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
version=$(cat package.json | jq -r '.version')
TAG=v$version
url="https://api.github.com/repos/patricklx/ember-hbs-imports/releases"
exists=$(curl -H "Content-Type: application/json" -H "Authorization: token $GITHUB_TOKEN" $url | jq ".[] | select(.tag_name == \"$TAG\") | .id")
if [[ -z $exists ]]; then
npm i lerna-changelog || echo "its okay"
export GITHUB_AUTH=$GITHUB_TOKEN
changelog=$(./node_modules/.bin/lerna-changelog)
curl -X POST -H "Content-Type: application/json" -H "Authorization: token $GITHUB_TOKEN" $url -d "{ \"tag_name\": \"$TAG\", \"name\": \"$TAG\", \"body\": \"$changelog\", \"draft\": false, \"prerelease\": false}"
else
echo "release already exists";
fi;