-
Notifications
You must be signed in to change notification settings - Fork 2
109 lines (98 loc) · 3.31 KB
/
build-release.yaml
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
name: Build and release version as draft
on:
workflow_dispatch:
push:
tags:
- "v*"
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
version: ${{ steps.pckg_ver.outputs.version }}
steps:
- name: Checkout package.json
uses: actions/checkout@v3
with:
sparse-checkout: |
.github/actions
- name: "Get package version and check if release exists"
uses: actions/github-script@v6
id: pckg_ver
with:
result-encoding: string
script: |
try {
const pckgJson = require('./package.json');
const v = pckgJson.version;
core.setOutput('version', v);
console.log("Package version is", v);
const { owner, repo } = context.repo;
const tag = "v" + v;
let exists = false;
try {
const releases = await github.rest.repos.listReleases({ owner, repo });
exists = !!releases.data.find((r) => r.tag_name == tag );
}
catch { }
console.log("Release for tag", tag, "already exists:", exists);
core.setOutput('release_exists', exists);
} catch(err) {
core.setFailed(err)
}
- name: "Get release notes"
if: ${{ steps.pckg_ver.outputs.release_exists == 'false' }}
uses: ./.github/actions/get-release-notes
id: release_notes
with:
version_tag: ${{ steps.pckg_ver.outputs.version }}
fallback_to_latest: true
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
with:
tag: v${{ steps.pckg_ver.outputs.version }}
name: ${{ steps.release_notes.outputs.release_title }}
body: ${{ steps.release_notes.outputs.release_notes }}
draft: true
prerelease: true
allowUpdates: true
updateOnlyUnreleased: true
skipIfReleaseExists: false
removeArtifacts: true
omitBodyDuringUpdate: true
omitDraftDuringUpdate: true
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true
build:
name: Build
needs: release
strategy:
fail-fast: false
matrix:
os: [ windows-latest, macos-latest, ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 18
- name: Checkout repository
uses: actions/checkout@v3
- name: NPM install
run: |
npm install
mkdir ./Installers
- name: Build
run: npm run build -- -p ${{ runner.os }}
- name: Upload assets
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./Installers/touchportal-dynamic-icons-${{ runner.os }}-${{ needs.release.outputs.version }}.tpp
asset_name: touchportal-dynamic-icons-${{ runner.os }}-${{ needs.release.outputs.version }}.tpp
asset_content_type: application/zip