-
Notifications
You must be signed in to change notification settings - Fork 189
85 lines (77 loc) · 3.03 KB
/
release_patch.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
81
82
83
84
85
name: Patch Release
on:
workflow_dispatch:
# schedule:
# - cron: "0 */1 * * *" # every wednesday
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.RELEASER_TOKEN }}
- name: Find release branch & current tag
shell: bash
id: extract_branch
run: |
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
echo "##[set-output name=current_tag;]$(cat VERSION.txt | sed -n 1p)"
echo "##[set-output name=current_commit;]$(cat VERSION.txt | sed -n 2p)"
echo "##[set-output name=last_commit;]$(git rev-parse HEAD)"
- name: Compute diff since last release
id: diff
run: |
export DIFF=$(git log ${CURRENT_COMMIT}..${LAST_COMMIT} --oneline)
DIFF="${DIFF//'%'/'%25'}"
DIFF="${DIFF//$'\n'/'%0A'}"
DIFF="${DIFF//$'\r'/'%0D'}"
echo "::set-output name=diff::${DIFF}"
env:
CURRENT_COMMIT: ${{ steps.extract_branch.outputs.current_commit }}
LAST_COMMIT: ${{ steps.extract_branch.outputs.last_commit }}
- name: Update VERSION
if: ${{ env.DIFF != '' }}
id: bump
run: |
./bin/update-version ${CURRENT_TAG%.*} $RELEASE_BRANCH
export NEW_TAG=$(cat VERSION.txt | sed -n 1p)
echo "::set-output name=tag::${NEW_TAG}"
git config --global user.name ClaroBot
git config --global user.email [email protected]
git add VERSION.txt
git commit -m "Release version ${NEW_TAG}"
git push origin $RELEASE_BRANCH
env:
DIFF: ${{ steps.diff.outputs.diff}}
RELEASE_BRANCH: ${{ steps.extract_branch.outputs.branch }}
CURRENT_TAG: ${{ steps.extract_branch.outputs.current_tag }}
- name: Create Tag
if: ${{ env.DIFF != '' }}
uses: anothrNick/[email protected]
env:
DIFF: ${{ steps.diff.outputs.diff}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_BRANCHES: ${{ steps.extract_branch.outputs.branch }}
CUSTOM_TAG: ${{ steps.bump.outputs.tag }}
- name: Create Release
if: ${{ env.DIFF != '' }}
uses: actions/create-release@v1
env:
DIFF: ${{ steps.diff.outputs.diff}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.bump.outputs.tag }}
release_name: v${{ steps.bump.outputs.tag }}
body: ${{ steps.diff.outputs.diff }}
- name: Repository Dispatch
if: ${{ env.DIFF != '' }}
uses: peter-evans/repository-dispatch@v1
env:
DIFF: ${{ steps.diff.outputs.diff}}
with:
token: ${{ secrets.FL_REPO_ACCESS_TOKEN }}
repository: FormaLibre/ClarolineBundle/
event-type: newtag
client-payload: '{"tag": "${{ steps.bump.outputs.tag }}", "releaseBranch": "${{ steps.extract_branch.outputs.branch }}"}'