-
Notifications
You must be signed in to change notification settings - Fork 185
182 lines (154 loc) · 5.74 KB
/
stage.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
180
181
182
---
name: Stage
on:
workflow_dispatch:
push:
branches:
- master
paths-ignore:
- '**/*.md'
- .github/workflows/**
jobs:
build:
runs-on: ubuntu-latest
if: github.repository_owner == 'fabric8-analytics'
name: Build plugin
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://npm.pkg.github.com'
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create .npmrc
run: |
echo "@RHEcosystemAppEng:registry=https://npm.pkg.github.com" > ~/.npmrc
echo "@fabric8-analytics:registry=https://npm.pkg.github.com" >> ~/.npmrc
- name: Install @vscode/vsce
run: npm i -g @vscode/vsce
- name: Install Dependencies
run: npm ci
- name: Compile for test
run: npm run test-compile
- name: VSCE package
run: vsce package --out fabric8-analytics-early-access.vsix
- name: Upload vsix package as artifact
uses: actions/upload-artifact@v3
with:
name: vsix
path: ./fabric8-analytics-early-access.vsix
release:
permissions: write-all
runs-on: ubuntu-latest
name: Create an early-access release
environment: staging
needs: build
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Configure git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Update package with new version
id: bump
run: |
echo "version=$(npm version ${{ vars.VERSION_BUMPING_TYPE }} --no-git-tag-version)" >> "$GITHUB_OUTPUT"
- name: Create release notes from changelog
id: release-notes
run: |
version="${{ steps.bump.outputs.version }}"
version=${version#v}
notes=$(sed -n "/## $version/,/^##/p" ./CHANGELOG.md | grep -v '##')
if [ -z "$notes" ]; then
echo "Release notes are missing for version $version."
exit 1
else
echo "version=$version" >> "$GITHUB_OUTPUT"
notes="${notes//$'\''/%27}"
notes="${notes//$'\n'/'%0A'}"
notes="${notes//$'\r'/'%0D'}"
delimiter="$(openssl rand -hex 8)"
echo "notes<<${delimiter}" >> "$GITHUB_OUTPUT"
echo "$notes" >> "$GITHUB_OUTPUT"
echo "${delimiter}" >> "$GITHUB_OUTPUT"
fi
- name: Update current version date in changelog
run: |
day_suffix=$(date +"%e" | sed 's/^[[:space:]]*//')
if [ "$day_suffix" = "1" ] || [ "$day_suffix" = "21" ] || [ "$day_suffix" = "31" ]; then
suffix="st"
elif [ "$day_suffix" = "2" ] || [ "$day_suffix" = "22" ]; then
suffix="nd"
elif [ "$day_suffix" = "3" ] || [ "$day_suffix" = "23" ]; then
suffix="rd"
else
suffix="th"
fi
today="$(date +"%b %-d")$suffix $(date +"%Y")"
version="${{ steps.release-notes.outputs.version }}"
if grep -qE "## $version \([^)]*\)" ./CHANGELOG.md; then
current_date=$(grep -oP "(?<=## $version \()[^\)]*" ./CHANGELOG.md)
if [ "$current_date" != "$today" ]; then
sed -E -i "s/## $version \([^)]*\)/## $version ($today)/" CHANGELOG.md
fi
else
sed -E -i "s/## $version/## $version ($today)/" CHANGELOG.md
fi
- name: Download vsix package artifact
uses: actions/download-artifact@v3
with:
name: vsix
path: ./vsix
- name: Commit and push package modifications
run: |
git add CHANGELOG.md
git add package.json
git add package-lock.json
git commit -m "build: updated package with ${{ steps.bump.outputs.version }} [skip ci]"
git push
- name: Create and push new tag
run: |
git tag ${{ steps.bump.outputs.version }} -m "${{ steps.bump.outputs.version }}"
git push origin ${{ steps.bump.outputs.version }}
- name: Create a release
id: new_release
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const repo_name = context.payload.repository.full_name
const response = await github.request('POST /repos/' + repo_name + '/releases', {
tag_name: '${{ steps.bump.outputs.version }}',
name: '${{ steps.bump.outputs.version }}',
body: '${{ steps.release-notes.outputs.notes }}',
prerelease: false,
generate_release_notes: true
})
core.setOutput('upload_url', response.data.upload_url)
- name: Create SHA256 checksums for the binaries
working-directory: vsix
run: |
for pkg in *
do
sha256sum "$pkg" > "$pkg.sha256"
done
- name: Upload packages and checksums as early-access release assets
working-directory: vsix
run: |
for file in *
do
asset_name=$(basename "$file")
upload_url=$(echo "${{ steps.new_release.outputs.upload_url }}" | sed "s/{?name,label}/?name=$asset_name/g")
curl --data-binary @"$file" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
"$upload_url"
done