forked from jyqq163/keycloak-services-social-weixin
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (68 loc) · 2.57 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
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Release Workflow
on:
workflow_run:
workflows: [ "Java CI with Maven" ]
branches: [ master ]
types:
- completed
jobs:
release:
name: Release Process
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Java CI with Maven artifacts
uses: actions/download-artifact@v4
with:
name: java-artifacts
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Set up JDK 18
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '18'
- name: Get latest tag
id: get_latest_tag
run: |
git fetch --tags
latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "::set-output name=latest_tag::$latest_tag"
- name: Get current version from pom.xml
id: get_current_version
run: |
current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "::set-output name=current_version::$current_version"
- name: Check if pom.xml version has changed
id: check_version
run: |
if [ "${{ steps.get_current_version.outputs.current_version }}" != "${{ steps.get_latest_tag.outputs.latest_tag }}" ]; then
echo "Version changed"
echo "::set-output name=version_changed::true"
else
echo "Version not changed"
echo "::set-output name=version_changed::false"
fi
- name: Create and Push Tag
id: push_tag
if: steps.check_version.outputs.version_changed == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git tag -a "${{ steps.get_current_version.outputs.current_version }}" -m "Generated tag from GitHub Actions"
git push origin "${{ steps.get_current_version.outputs.current_version }}"
ls -al
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
id: create_release
if: steps.check_version.outputs.version_changed == 'true'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_current_version.outputs.current_version }}
release_name: Release ${{ steps.get_current_version.outputs.current_version }}
draft: false
prerelease: false