-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (68 loc) · 2.98 KB
/
create-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
name: 'Create Release'
on:
workflow_dispatch:
inputs:
releaseVersion:
description: 'Version de la release (semver)'
required: true
default: 'x.x.x'
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: 'Checkout source code'
uses: 'actions/checkout@v3'
with:
fetch-depth: '0' # to get all the tags locally
# https://stackoverflow.com/questions/67550727/push-event-doesnt-trigger-workflow-on-push-paths-github-actions
token: ${{ secrets.TOKEN_GITHUB_FOR_GITHUB_ACTION }}
- name: 'Verify release is created only on "main" or "master" git branch'
run: |
CURRENT_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo $CURRENT_GIT_BRANCH
[[ "$CURRENT_GIT_BRANCH" == "main" || "$CURRENT_GIT_BRANCH" == "master" ]] && exit 0 || exit 1
- name: 'Verify version is semver formatted (X.X.X)'
env:
NEW_TAG: ${{ github.event.inputs.releaseVersion }}
run: |
echo $NEW_TAG | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$'
- name: 'Verify version is not already used as a git tag'
env:
NEW_TAG: ${{ github.event.inputs.releaseVersion }}
run: |
[[ "$(git tag --list | grep $NEW_TAG)" == "" ]] && exit 0 || exit 1
- name: 'Generate the new version (patch few files + git tag)'
env:
NEW_TAG: ${{ github.event.inputs.releaseVersion }}
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB_FOR_GITHUB_ACTION }}
run: |
# préparation de la release qui va :
# - modifier le numéro de version dans les pom.xml du projet
# - créer un tag git du numéro de version en question
# - pousser le tout sur le dépôt github
git config --global user.email "github-action@noreply"
git config --global user.name "Github Action"
mvn --batch-mode release:update-versions \
-DautoVersionSubmodules=true \
-DdevelopmentVersion=${NEW_TAG}-SNAPSHOT
git add -- pom.xml core/pom.xml batch/pom.xml web/pom.xml
git commit -m '[Prepare version] [no ci]'
git push
# add TAG $NEW_TAG
git commit --amend -m "Version $NEW_TAG"
git tag $NEW_TAG
git push origin $NEW_TAG
# merge la préparation de la nouvelle version sur develop
# (version X.X.X-SNAPSHOT)
# CURRENT_GIT_BRANCH vaut main ou master, c'est la où est créé la release
CURRENT_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
#git switch develop
#git merge --no-commit $CURRENT_GIT_BRANCH
#git commit -m "[skip ci]"
#git push
- name: 'Create the github release'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.releaseVersion }}
generate_release_notes: true
token: ${{ secrets.TOKEN_GITHUB_FOR_GITHUB_ACTION }}