@@ -3,82 +3,89 @@ name: Release
3
3
on :
4
4
workflow_call :
5
5
inputs :
6
- release_branch :
7
- description : The release base branch
6
+ version :
7
+ description : The release version to create.
8
8
required : true
9
9
type : string
10
10
11
11
jobs :
12
12
release :
13
- env :
14
- source_path : " ./source"
15
13
runs-on : ubuntu-latest
16
14
permissions :
17
15
contents : write
18
16
pull-requests : write
19
17
20
18
steps :
21
- - name : setup python
22
- uses : actions/setup-python@v4
19
+ - name : Checkout the repository
20
+ uses : actions/checkout@v3
23
21
with :
24
- python-version : " 3.9 "
22
+ fetch-depth : " 0 "
25
23
26
- - name : Install python required libraries
27
- run : pip install -U pygithub semver tox pyyaml
24
+ - name : Validate version format
25
+ run : |-
26
+ python -c "import os, re, sys;
27
+ version=os.environ.get('RELEASE_VERSION');
28
+ print('version <%s> is matching expecting format' % version) if re.match(r'^[0-9]+\.[0-9]+\.[0-9]+$', version) else sys.exit(1)"
28
29
shell: bash
30
+ env:
31
+ RELEASE_VERSION: ${{ inputs.version }}
29
32
30
- - name : Download python script
31
- run : >-
32
- curl -o create_release_branch.py
33
- https://raw.githubusercontent.com/ansible-network/github_actions/main/scripts/create_release_branch.py
34
-
35
- - name : Compute release version and create release branch
36
- id : compute-version
37
- run : >-
38
- python3 ./create_release_branch.py
33
+ - name: Create release branch on Github repository
34
+ id: create-branch
35
+ run: |
36
+ R_BRANCH="stable-$(echo ${RELEASE_VERSION} | cut -d '.' -f1)"
37
+ D_BRANCH=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')
38
+ echo "release_branch=$R_BRANCH" >> $GITHUB_OUTPUT
39
+ git checkout $D_BRANCH
40
+ git checkout -b $R_BRANCH && git push origin $R_BRANCH || git checkout $R_BRANCH
41
+ shell: bash
39
42
env:
40
- REPOSITORY_NAME : ${{ github.repository }}
41
- RELEASE_BRANCH : ${{ inputs.release_branch }}
42
43
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44
+ RELEASE_VERSION: ${{ inputs.version }}
43
45
44
- - name : Checkout the repository
45
- uses : actions/checkout@v3
46
+ - name: setup python
47
+ uses: actions/setup-python@v4
46
48
with:
47
- path : ${{ env.source_path }}
48
- fetch-depth : " 0"
49
- if : ${{ (steps.compute-version.outputs.release_version != '') }}
49
+ python-version: "3.9"
50
+
51
+ - name: Install required python modules
52
+ run: pip3 install tox yq
53
+ shell: bash
50
54
51
55
- name: Prepare release
52
56
run: tox -e prepare_release -vv
53
57
shell: bash
54
- working-directory : ${{ env.source_path }}
55
58
env:
56
- RELEASE_VERSION : ${{ steps.compute-version.outputs.release_version }}
57
- if : ${{ (steps.compute-version.outputs.release_version != '') }}
59
+ RELEASE_VERSION: ${{ inputs.version }}
58
60
59
- - name : Download python script used to update galaxy file
60
- run : >-
61
- curl -o update_galaxy_file.py
62
- https://raw.githubusercontent.com/ansible-network/github_actions/main/scripts/update_galaxy_file.py
63
- if : ${{ (steps.compute- version.outputs.release_version != '') }}
61
+ - name: Update galaxy.yml file
62
+ run: yq -yi ".version = \"$RELEASE_VERSION\"" galaxy.yml
63
+ shell: bash
64
+ env:
65
+ RELEASE_VERSION : ${{ inputs. version }}
64
66
65
- - name : Compute release version and create release branch
66
- run : >-
67
- python3 ./update_galaxy_file.py
67
+ - name: Push changes to branch on Github repository
68
+ id: push-changes
69
+ run: |
70
+ git checkout -b "prepare_release_${RELEASE_VERSION}"
71
+ git add -A
72
+ git -c user.name="$GIT_USER_NAME" -c user.email="$GIT_USER_EMAIL" commit -m "Release ${{ inputs.version }}" --author="$GIT_AUTHOR"
73
+ git push origin "prepare_release_${RELEASE_VERSION}"
74
+ echo "created_branch=prepare_release_${RELEASE_VERSION}" >> $GITHUB_OUTPUT
75
+ shell: bash
68
76
env:
69
- COLLECTION_PATH : ${{ env.source_path }}
70
- RELEASE_VERSION : ${{ steps.compute-version.outputs.release_version }}
71
- if : ${{ (steps.compute-version.outputs.release_version != '') }}
77
+ RELEASE_VERSION: ${{ inputs.version }}
78
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79
+ GIT_USER_NAME: "github-actions[bot]"
80
+ GIT_USER_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com"
81
+ GIT_AUTHOR: "${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>"
72
82
73
83
- name: Create Pull Request
74
- uses : peter-evans/create-pull-request@v5
84
+ uses: abikouo/github_actions/.github/actions/create_pullrequest@release_v4
75
85
with:
76
86
token: ${{ secrets.GITHUB_TOKEN }}
77
- path : ${{ env.source_path }}
78
- commit-message : " Release ${{ steps.compute-version.outputs.release_version }}"
79
- base : ${{ inputs.release_branch }}
80
- branch : " prepare_release_${{ steps.compute-version.outputs.release_version }}"
81
- title : " Prepare release ${{ steps.compute-version.outputs.release_version }}"
82
- body : |
83
- Release ${{ steps.compute-version.outputs.release_version }}
84
- if : ${{ (steps.compute-version.outputs.release_version != '') }}
87
+ repository: ${{ github.repository }}
88
+ base_branch: ${{ steps.create-branch.outputs.release_branch }}
89
+ head_branch: ${{ steps.push-changes.outputs.created_branch }}
90
+ title: "Prepare release ${{ inputs.version }}"
91
+ body: "Automatic changes for Release ${{ inputs.version }}"
0 commit comments