-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (129 loc) · 4.49 KB
/
release.yml
File metadata and controls
146 lines (129 loc) · 4.49 KB
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
name: Release
on:
push:
tags:
- "v*"
branches:
- main
workflow_dispatch:
permissions:
contents: write
jobs:
version-check:
name: Version check
runs-on: ubuntu-latest
outputs:
version: ${{ steps.check.outputs.version }}
tag: ${{ steps.check.outputs.tag }}
should_build: ${{ steps.check.outputs.should_build }}
should_release: ${{ steps.check.outputs.should_release }}
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 20
- name: Check version
id: check
run: |
set -euo pipefail
SHOULD_BUILD="true"
SHOULD_RELEASE="true"
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
TAG_NAME="${GITHUB_REF_NAME}"
VERSION="${GITHUB_REF_NAME#v}"
else
VERSION="$(node -p "require('./package.json').version")"
TAG_NAME="v${VERSION}"
fi
if [[ "${GITHUB_EVENT_NAME}" == "push" && "${GITHUB_REF_TYPE}" != "tag" ]]; then
BEFORE_SHA="$(node -p "require(process.env.GITHUB_EVENT_PATH).before")"
if [[ -n "${BEFORE_SHA}" && "${BEFORE_SHA}" != "0000000000000000000000000000000000000000" ]]; then
if git show "${BEFORE_SHA}:package.json" >/dev/null 2>&1; then
PREV_VERSION="$(git show "${BEFORE_SHA}:package.json" | node -e "const fs=require('fs'); const pkg=JSON.parse(fs.readFileSync(0,'utf8')); console.log(pkg.version||'');")"
if [[ "${PREV_VERSION}" == "${VERSION}" ]]; then
SHOULD_BUILD="false"
SHOULD_RELEASE="false"
fi
fi
fi
fi
if [[ "${GITHUB_REF_TYPE}" != "tag" ]]; then
if git show-ref --tags --quiet "refs/tags/${TAG_NAME}"; then
SHOULD_RELEASE="false"
fi
fi
if [[ "${SHOULD_BUILD}" != "true" ]]; then
SHOULD_RELEASE="false"
fi
{
echo "version=${VERSION}"
echo "tag=${TAG_NAME}"
echo "should_build=${SHOULD_BUILD}"
echo "should_release=${SHOULD_RELEASE}"
} >> "$GITHUB_OUTPUT"
build:
name: Build (${{ matrix.os }})
needs: version-check
if: needs.version-check.outputs.should_build == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
artifact_name: release-macos
artifact_path: release/*.dmg
- os: windows-latest
artifact_name: release-windows
artifact_path: release/*.exe
- os: ubuntu-latest
artifact_name: release-linux
artifact_path: release/*.AppImage
env:
CSC_IDENTITY_AUTO_DISCOVERY: "false"
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Setup Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Build release
run: npm run dist
- name: Upload artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_path }}
if-no-files-found: error
release:
name: Create Release
runs-on: ubuntu-latest
needs: [version-check, build]
if: needs.version-check.outputs.should_release == 'true'
steps:
- name: Download artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
path: release-artifacts
- name: Publish release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
with:
tag_name: ${{ needs.version-check.outputs.tag }}
name: API Key Health Checker ${{ needs.version-check.outputs.version }}
draft: false
prerelease: false
generate_release_notes: true
files: |
release-artifacts/**/*.dmg
release-artifacts/**/*.exe
release-artifacts/**/*.AppImage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}