forked from DamianMorozov/OpenTgResearcher
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (77 loc) · 2.59 KB
/
action_preview_create.yml
File metadata and controls
80 lines (77 loc) · 2.59 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
70
71
72
73
74
75
76
77
78
79
80
name: Create new version preview
permissions:
contents: write
on:
workflow_dispatch:
push:
tags:
- 'v*'
branches: [preview]
paths:
- 'CHANGELOG.md'
jobs:
build_windows:
uses: ./.github/workflows/action_build_windows.yml
with:
target: windows
release:
needs: [build_windows]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get latest version from CHANGELOG
id: get_version
run: echo "version=$(grep '^## \[' Docs/CHANGELOG.md | head -n1 | sed 's/^## \[\(.*\)\].*/\1/')" >> $GITHUB_OUTPUT
- name: Get release description from CHANGELOG
id: get_body
run: |
{
echo 'body<<EOF'
awk '/^## \[/ {i++} i==1 {print}' Docs/CHANGELOG.md
echo 'EOF'
} >> "$GITHUB_OUTPUT"
- name: Download OpenTgResearcherConsole-win-Portable artifact
uses: actions/download-artifact@v4
with:
name: OpenTgResearcherConsole-win-Portable
path: ./artifacts
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Configure Git
run: |
git config --global user.name "Damian Viktorovich Morozov"
git config --global user.email "damian@morozov33.ru"
- name: Check if tag exists
id: check_tag
run: |
if git rev-parse "${{ steps.get_version.outputs.version }}" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Exit if tag already exists
if: steps.check_tag.outputs.exists == 'true'
run: echo "Tag already exists. Exiting..."
- name: Create annotated Git tag
if: steps.check_tag.outputs.exists == 'false'
run: |
git tag -a "v${{ steps.get_version.outputs.version }}" -m "$(cat <<EOF
${{ steps.get_body.outputs.body }}
EOF
)"
git push origin "v${{ steps.get_version.outputs.version }}"
- name: Create GitHub Release
if: steps.check_tag.outputs.exists == 'false'
run: |
gh auth setup-git
gh release create "v${{ steps.get_version.outputs.version }}" ./artifacts/* \
--title "v${{ steps.get_version.outputs.version }} Preview" \
--notes "${{ steps.get_body.outputs.body }}" \
--prerelease
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}