-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yaml
More file actions
69 lines (62 loc) · 2.45 KB
/
action.yaml
File metadata and controls
69 lines (62 loc) · 2.45 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
67
68
69
name: Release
description: Create release
inputs:
GITHUB_TOKEN:
description: "GITHUB_TOKEN"
required: true
target_branch:
description: "Target branch for releases."
default: dev
outputs:
NEW_RELEASE:
description: "Equal to true if there is new release, false if not."
value: ${{ steps.new_release.outputs.NEW_RELEASE }}
NEW_VERSION:
description: "New release version."
value: ${{ steps.release_version.outputs.NEW_VERSION }}
runs:
using: "composite"
steps:
- name: Check if there is new release
id: new_release
shell: bash
env:
GH_TOKEN: ${{inputs.GH_TOKEN}}
NPM_TOKEN: ${{inputs.GH_TOKEN}}
run: |
new_release=$(source .venv/bin/activate && \
python -c "import subprocess; \
semantic_release_output = subprocess.check_output(['semantic-release', 'version', '--noop'], stderr=subprocess.STDOUT, text=True); \
no_release_count = semantic_release_output.count('No release will be made'); \
new_release = True if no_release_count == 0 else False; \
print(str(new_release))")
echo "new_release=${new_release}"
echo "NEW_RELEASE=${new_release}" >> $GITHUB_OUTPUT
echo "NEW_RELEASE=${new_release}"
- name: Release version
id: release_version
shell: bash
env:
GH_TOKEN: ${{inputs.GH_TOKEN}}
NPM_TOKEN: ${{inputs.GH_TOKEN}}
run: |
new_version=$(source .venv/bin/activate && \
python -c "import subprocess, re; \
semantic_release_output = subprocess.check_output(['semantic-release', 'version', '--noop'], stderr=subprocess.STDOUT, text=True); \
raw_release_info = semantic_release_output if 'bump' in semantic_release_output else 'no_release'; \
match = re.search(r'bumped from (\d+\.\d+\.\d+) to (\d+\.\d+\.\d+)', raw_release_info); \
new_version = match.group(2) if match else 'NO NEW RELEASE'; \
print(new_version)")
echo "NEW_VERSION=${new_version}" >> $GITHUB_OUTPUT
echo "NEW_VERSION=${new_version}"
- name: Publish release
if: github.ref == 'refs/heads/${{inputs.target_branch}}'
shell: bash
env:
GH_TOKEN: ${{inputs.GITHUB_TOKEN}}
run: |
source .venv/bin/activate
git config user.name github-actions
git config user.email github-actions@github.com
semantic-release publish -v DEBUG
git push origin HEAD:${{inputs.target_branch}}