generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (48 loc) · 1.65 KB
/
ci.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
name: Release Workflow
on:
push:
paths:
- "dist/index.cjs"
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Get version from commit message
id: version
run: echo "::set-output name=version::$(git log -1 --pretty=%B | grep -oP '\[v ([0-9]+\.[0-9]+\.[0-9]+)\]' | sed 's/\[v \|\]//g')"
- name: Validate version format
run: |
if [[ ! "${{ steps.version.outputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version format. Aborting the workflow."
exit 1
fi
- name: Update package.json
run: |
sed -i "s/\"version\": \".*\"/\"version\": \"${{ steps.version.outputs.version }}\"/" package.json
- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "inlang-bot"
git add package.json
git commit -m "Bump version to ${{ steps.version.outputs.version }}"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
files: 'dist/*'
token: ${{ secrets.GITHUB_TOKEN }}
body: |
Release ${{ steps.version.outputs.version }}
tag_name: v${{ steps.version.outputs.version }}