-
Notifications
You must be signed in to change notification settings - Fork 10
79 lines (69 loc) · 2.45 KB
/
release.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
---
name: Build
on:
push:
tags:
- v*
paths-ignore:
# Do not run the pipeline if only Markdown files changed
- '**.yaml'
- '**.md'
jobs:
release:
name: create release
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
- name: get release version
id: release_version
run: |
TAGGED_VERSION="${GITHUB_REF/refs\/tags\/v/}"
if [[ ! "${TAGGED_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
echo "Invalid version tag '${TAGGED_VERSION}'"
exit 1
fi
echo "EXT_VERSION=${TAGGED_VERSION}" >> $GITHUB_ENV
WRITTEN_VERSION="$(cat package.json | jq '.version' -r)"
if [[ "${TAGGED_VERSION}" == *"-"* ]]; then
if [[ ! "${TAGGED_VERSION}" == "${WRITTEN_VERSION}"-rc.* ]]; then
echo "Prerelease Tag and Version in package.json are not compatible: '${TAGGED_VERSION}' vs '${WRITTEN_VERSION}'"
exit 1
fi
echo "EXT_ISPREVIEW=1" >> $GITHUB_ENV
else
if [[ "${TAGGED_VERSION}" != "${WRITTEN_VERSION}" ]]; then
echo "Release Tag and Version in package.json do not match: '${TAGGED_VERSION}' vs '${WRITTEN_VERSION}'"
exit 1
fi
echo "EXT_ISPREVIEW=0" >> $GITHUB_ENV
fi
- name: stamp version
run: |
cat package.json | jq --arg VER "${{ env.EXT_VERSION }}" '.version=$VER' > /tmp/package.json
cp /tmp/package.json ./package.json
npm ci
npm run vscode:prepublish
- name: package
uses: lannonbr/vsce-action@0f3391ee0477b08fae949eb0a875e91e6d20b075
with:
args: "package"
- name: create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ env.EXT_VERSION }}
draft: false
prerelease: ${{env.EXT_ISPREVIEW == 1}}
- name: upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./kubescape-${{ env.EXT_VERSION }}.vsix
asset_name: kubescape-${{ env.EXT_VERSION }}.vsix
asset_content_type: application/zip