-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (55 loc) · 1.86 KB
/
release.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
name: Create Tag and Release on Version Change
on:
push:
branches:
- master
permissions: write-all
jobs:
create_tag:
name: Create Git Tag
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check for version changes
run: |
# Fetch all tags from the remote repository
git fetch --tags
# Get the previous version from the last release tag
export previous_version=$(git describe --tags --abbrev=0)
# Get the current version from pubspec.yaml
export current_version=$(cat pubspec.yaml | grep 'version:' | awk '{print $2}')
if [[ "$previous_version" != "v$current_version" ]]; then
echo "Version has changed from $previous_version to v$current_version."
else
echo "Version has not changed."
exit 1
fi
- name: Push Git Tag
run: |
# Git login
git config --global user.name "$(git log -n 1 --pretty=format:%an)"
git config --global user.email "$(git log -n 1 --pretty=format:%ae)"
# Push a Git tag with the new version
export current_version=$(cat pubspec.yaml | grep 'version:' | awk '{print $2}')
git tag -a "v$current_version" -m "Version $current_version"
git push origin "v$current_version"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: create_tag
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Create Release
run: gh release create "$(git describe --tags --abbrev=0)" --generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}