generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 2
94 lines (85 loc) · 2.66 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
89
90
91
92
93
94
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:
changelog:
name: Changelog
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.changelog.outputs.tag }}
version: ${{ steps.changelog.outputs.version }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Conventional Changelog Update
uses: TriPSs/conventional-changelog-action@v5
id: changelog
continue-on-error: true
with:
github-token: ${{ github.token }}
output-file: 'CHANGELOG.md'
skip-version-file: 'true'
skip-commit: 'true'
skip-on-empty: 'false'
git-push: 'true'
- uses: actions/upload-artifact@v4.3.6
with:
path: CHANGELOG.md
release:
name: Release (if necessary)
needs: changelog
if: ${{ needs.changelog.outputs.version != '' }}
env:
TEMP_BRANCH: ${{ github.head_ref }}-release-${{ github.run_number }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4.0.3
with:
node-version: 20.x
- uses: actions/download-artifact@v4.1.8
with:
name: my-artifact
path: path/to/artifact
- name: Rebuild and push the dist/ directory
run: |
npm run dist
git diff ./dist
if $(git diff --ignore-space-at-eol --quiet ./dist); then
git checkout -b ${{ env.TEMP_BRANCH }}
git add ./dist
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.name "${GITHUB_ACTOR}"
git add .
git commit -m "Rebuild dist/ directory"
git push -u origin HEAD:${{ env.TEMP_BRANCH }}
gh release create ${{ needs.changelog.outputs.tag }} --title ${{ needs.changelog.outputs.tag }} --notes-file CHANGELOG.md
git branch -D ${{ env.TEMP_BRANCH }}
fi
# - name: Create Release
# uses: softprops/action-gh-release@v2
# continue-on-error: true
# env:
# GITHUB_TOKEN: ${{ github.token }}
# with:
# token: ${{ github.token }}
# tag_name: ${{ needs.changelog.outputs.tag }}
# name: ${{ needs.changelog.outputs.tag }}
# body: ${{ needs.changelog.outputs.clean_changelog }}