-
Notifications
You must be signed in to change notification settings - Fork 6
179 lines (149 loc) · 4.47 KB
/
build.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Build
on:
push:
pull_request:
release:
types: [published]
permissions: write-all
jobs:
build:
runs-on: ubuntu-latest
if: >
github.event_name == 'push' ||
github.event.pull_request.head.repo.full_name != github.repository
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Use Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Lint and Test
run: deno task test
- name: Build
run: deno task build
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Verify No Unstaged Changes
run: |
if [[ "$(git status --porcelain)" != "" ]]; then
echo git status
git status
echo git diff
git diff
echo "::error::Unstaged changes detected."
exit 1
fi
compile:
runs-on: ubuntu-latest
if: >
github.event_name == 'push' ||
github.event.pull_request.head.repo.full_name != github.repository
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Use Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Build
run: deno task compile
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: gh-describe-canary
path: ./dist/gh-describe-*
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
if: >
github.event_name == 'push' ||
github.event.pull_request.head.repo.full_name != github.repository
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Use Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Install on GitHub CLI Extensions
run: gh extensions install .
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Test Run on GitHub CLI Extensions with Deno
run: |
gh describe --runtime deno --version
gh describe --runtime deno
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Test Run on GitHub CLI Extensions with Node.js
run: |
gh describe --runtime node --version
gh describe --runtime node
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Test Run on Deno Run
shell: bash
run: |
deno run --allow-run https://raw.githubusercontent.com/proudust/gh-describe/"${GITHUB_SHA}"/main.ts --version
deno run --allow-run https://raw.githubusercontent.com/proudust/gh-describe/"${GITHUB_SHA}"/main.ts
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Test Run on GitHub Actions
id: ghd
uses: ./
- name: Check outputs
run: |
echo "describe : ${{ steps.ghd.outputs.describe }}"
echo "tag : ${{ steps.ghd.outputs.tag }}"
echo "distance : ${{ steps.ghd.outputs.distance }}"
echo "sha : ${{ steps.ghd.outputs.sha }}"
echo "short-sha : ${{ steps.ghd.outputs.short-sha }}"
release:
runs-on: ubuntu-latest
if: >
startsWith(github.ref, 'refs/tags/') ||
github.event_name == 'release'
needs:
- build
- compile
- test
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore
uses: actions/download-artifact@v4
with:
name: gh-describe-canary
path: ./dist
- name: Run gh-describe
id: ghd
uses: ./
- name: Create Release and Upload Files
run: |
if gh release view "${GITHUB_RELEASE_TAG}" --json tagName >/dev/null && echo 'release found'; then
gh release upload --clobber "${GITHUB_RELEASE_TAG}" ./dist/gh-describe-*
else
gh release create -d --generate-notes "${GITHUB_RELEASE_TAG}" ./dist/gh-describe-*
fi
env:
GITHUB_RELEASE_TAG: ${{ steps.ghd.outputs.tag }}
GITHUB_TOKEN: ${{ github.token }}