Skip to content

Commit 31ab27c

Browse files
committed
Bump version and change release type when publishing a new version
1 parent a13606b commit 31ab27c

File tree

1 file changed

+84
-1
lines changed

1 file changed

+84
-1
lines changed

.github/workflows/build.yml

+84-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: Build YouTube Music
33
on:
44
- push
55

6+
env:
7+
NODE_VERSION: "16.x"
8+
69
jobs:
710
build:
811
name: Build YouTube Music
@@ -18,7 +21,7 @@ jobs:
1821
- name: Setup NodeJS
1922
uses: actions/setup-node@v3
2023
with:
21-
node-version: "16.x"
24+
node-version: ${{ env.NODE_VERSION }}
2225

2326
- name: Get yarn cache directory path
2427
id: yarn-cache-dir-path
@@ -116,3 +119,83 @@ jobs:
116119
GH_TOKEN: ${{ secrets.GH_TOKEN }}
117120
run: |
118121
yarn run release:win
122+
123+
release:
124+
runs-on: ubuntu-latest
125+
name: Release YouTube Music
126+
if: github.ref == 'refs/heads/master'
127+
needs: build
128+
steps:
129+
- uses: actions/checkout@v3
130+
with:
131+
fetch-depth: 0
132+
133+
- name: Setup NodeJS
134+
uses: actions/setup-node@v3
135+
with:
136+
node-version: ${{ env.NODE_VERSION }}
137+
138+
- name: Get yarn cache directory path
139+
id: yarn-cache-dir-path
140+
run: echo "::set-output name=dir::$(yarn cache dir)"
141+
142+
- uses: actions/cache@v3
143+
id: yarn-cache
144+
with:
145+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
146+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
147+
restore-keys: |
148+
${{ runner.os }}-yarn-
149+
150+
- name: Install dependencies
151+
run: yarn --frozen-lockfile
152+
153+
- name: Get version
154+
run: |
155+
echo "VERSION_TAG=v$(node -pe "require('./package.json').version")" >> $GITHUB_ENV
156+
157+
- name: Check if version already exists in tags
158+
run: |
159+
echo "VERSION_HASH=$(git rev-parse -q --verify 'refs/tags/${{ env.VERSION_TAG }}')" >> $GITHUB_ENV
160+
echo "CHANGELOG_ANCHOR=$(echo $VERSION_TAG | sed -e 's/\.//g')" >> $GITHUB_ENV
161+
162+
- name: Fetch draft release
163+
if: ${{ env.VERSION_HASH == '' }}
164+
uses: cardinalby/git-get-release-action@v1
165+
id: get_draft_release
166+
env:
167+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
168+
with:
169+
latest: true
170+
draft: true
171+
searchLimit: 1
172+
173+
- name: Publish Release (if it does not exist)
174+
if: ${{ env.VERSION_HASH == '' }}
175+
uses: irongut/[email protected]
176+
with:
177+
token: ${{ secrets.GH_TOKEN }}
178+
id: ${{ steps.get_draft_release.outputs.id }}
179+
draft: false
180+
prerelease: false
181+
replacename: true
182+
name: ${{ env.VERSION_TAG }}
183+
replacebody: true
184+
body: |
185+
See [changelog](https://github.com/th-ch/youtube-music/blob/master/changelog.md#${{ env.CHANGELOG_ANCHOR }}) for the list of updates and the full diff.
186+
187+
Thanks to all contributors! 🏅
188+
189+
- name: Update changelog
190+
if: ${{ env.VERSION_HASH == '' }}
191+
run: |
192+
yarn changelog
193+
194+
- name: Commit changelog
195+
if: ${{ env.VERSION_HASH == '' }}
196+
uses: stefanzweifel/git-auto-commit-action@v4
197+
with:
198+
commit_message: Update changelog for ${{ env.VERSION_TAG }}
199+
file_pattern: "changelog.md"
200+
commit_user_name: CI
201+
commit_user_email: [email protected]

0 commit comments

Comments
 (0)