generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 2
88 lines (79 loc) · 2.63 KB
/
merge.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
name: Merge
on:
# push:
# branches: [main]
# paths:
# - 'src/**'
# - 'package-lock.json'
# - 'package.json'
# - 'tsconfig.json'
# - 'action.yml'
# workflow_dispatch:
pull_request:
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
release:
name: Release
env:
branch: temp-${{ github.run_number }}
outputs:
next: ${{ steps.semver.outputs.next }}
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get Semver
id: semver
uses: ietf-tools/semver-action@v1
with:
token: ${{ github.token }}
- name: Git Setup
if: ${{ steps.semver.outputs.next }}
run: |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.name "${GITHUB_ACTOR}"
git checkout -b ${{ env.branch }}
- name: Rebuild ./dist
if: ${{ steps.semver.outputs.next }}
run: |
npm run dist
git add ./dist --force
git commit -m "Rebuild dist/ directory"
- name: Tag
if: ${{ steps.semver.outputs.next }}
env:
tag_semver: ${{ steps.semver.outputs.next }}
run: |
git push -u origin HEAD:${{ env.branch }}
git tag -f ${{ env.tag_semver }}
git push -f origin tag ${{ env.tag_semver }}
- name: Major Release
if: ${{ steps.semver.outputs.next }}
env:
GH_TOKEN: ${{ github.token }}
tag_semver: ${{ steps.semver.outputs.next }}
tag_major: ${{ steps.semver.outputs.nextMajor }}
run: |
if [ $(gh release view ${{ env.tag_major }} --json name -q .name) ]; then
gh release edit ${{ env.tag_major }} --title ${{ env.tag_major }} --tag ${{ env.tag_semver }}
else
gh release create ${{ env.tag_major }} --title ${{ env.tag_major }} --tag ${{ env.tag_semver }}
fi
- name: Semver Release
if: ${{ steps.semver.outputs.next }}
env:
GH_TOKEN: ${{ github.token }}
tag_semver: ${{ steps.semver.outputs.next }}
tag_major: ${{ steps.semver.outputs.nextMajor }}
run: |
if [ $(gh release view ${{ env.tag_semver }} --json name -q .name) ]; then
gh release delete ${{ env.tag_semver }} --yes
fi
gh release create ${{ env.tag_semver }} --title ${{ env.tag_semver }} --generate-notes
- name: Cleanup
if: always() && ${{ steps.semver.outputs.next }}
run: |
git push --delete origin ${{ env.branch }}