-
-
Notifications
You must be signed in to change notification settings - Fork 3
66 lines (55 loc) · 1.93 KB
/
Copy pathrelease.yml
File metadata and controls
66 lines (55 loc) · 1.93 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
name: Release if bump version number
on:
push:
branches:
- master
paths:
- package.json
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions: { }
defaults:
run:
shell: bash
jobs:
check-bump-version:
if: github.event.pull_request.head.repo.fork == false # Skip on public fork
runs-on: ubuntu-slim
timeout-minutes: 5
permissions:
contents: read
outputs:
new-version: ${{ steps.diff.outputs.version }}
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
with:
fetch-depth: 100
- name: Get version number diff
run: |
version="$(git diff ${{ github.event.before }}..${{ github.event.after }} package.json | sed -nr '/^\+ +\"version\":/p' | sed -r 's/^.*\"([0-9a-z\.\-\+]+)\"*.$/\1/')"
echo "version=$version" >> "$GITHUB_OUTPUT"
id: diff
release:
needs: check-bump-version
if: ${{ needs.check-bump-version.outputs.new-version }}
runs-on: ubuntu-slim
timeout-minutes: 5
permissions:
contents: write
pull-requests: read
actions: read
steps:
- uses: release-drafter/release-drafter@b1476f6e6eb133afa41ed8589daba6dc69b4d3f5 # v6
with:
config-name: release-drafter.yml
version: v${{ needs.check-bump-version.outputs.new-version }}
publish: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Update major and latest branch # for GitHub Actions, see https://github.com/actions/toolkit/blob/master/docs/action-versioning.md#versioning
run: |
major=$(echo v"${{ needs.check-bump-version.outputs.new-version }}" | sed -r 's/(v[0-9]+).*/\1/')
git push --force origin "HEAD:refs/heads/$major"
git push --force origin "HEAD:refs/heads/latest"