generated from gapitio/htmlgraphics-html-bundler-template
-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (74 loc) · 2.95 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
80
81
82
83
84
85
86
87
88
89
90
name: Release
on:
push:
tags:
- "v*.*.*" # Run workflow on version tags, e.g. v1.0.0.
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js environment
uses: actions/setup-node@v2
with:
node-version: "14.x"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Get metadata
id: metadata
run: |
sudo apt-get install jq
export NAME=$(cat package.json | jq -r .name)
export VERSION=$(cat package.json | jq -r .version)
export OUT_ZIP_FILE=${NAME}-${VERSION}.zip
export OUT_PANEL_OPTIONS_FILE=${NAME}-${VERSION}-panel-options.json
echo "::set-output name=name::${NAME}"
echo "::set-output name=version::${VERSION}"
echo "::set-output name=out-zip-file::${OUT_ZIP_FILE}"
echo "::set-output name=out-panel-options-file::${OUT_PANEL_OPTIONS_FILE}"
echo "::set-output name=github-tag::${GITHUB_REF#refs/*/}"
- name: Read changelog
id: changelog
run: |
awk '/^## / {s++} s == 1 {print}' CHANGELOG.md > release_notes.md
echo "::set-output name=path::release_notes.md"
- name: Check package version
run: if [ "v${{ steps.metadata.outputs.version }}" != "${{ steps.metadata.outputs.github-tag }}" ]; then printf "\033[0;31mPackage version doesn't match tag name\033[0m\n"; exit 1; fi
- name: Package project
run: |
cp dist ${{ steps.metadata.outputs.name }} -r
zip ${{ steps.metadata.outputs.out-zip-file }} ${{ steps.metadata.outputs.name }} -r
- 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 ${{ github.ref }}
body_path: ${{ steps.changelog.outputs.path }}
draft: true
- name: Add zip to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ steps.metadata.outputs.out-zip-file }}
asset_name: ${{ steps.metadata.outputs.out-zip-file }}
asset_content_type: application/zip
- name: Add panel options to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/panel-options.json
asset_name: ${{ steps.metadata.outputs.out-panel-options-file }}
asset_content_type: application/json
- name: Publish release
run: |
echo A draft release has been created. Please review and publish it.