1
+ name : Repository bumper
2
+ run-name : Bump ${{ github.ref_name }} (${{ inputs.id }})
3
+
4
+ on :
5
+ workflow_dispatch :
6
+ inputs :
7
+ version :
8
+ description : ' Target version (e.g. 4.12.0)'
9
+ default : ' '
10
+ required : false
11
+ type : string
12
+ stage :
13
+ description : ' Version stage (e.g. alpha0)'
14
+ default : ' '
15
+ required : false
16
+ type : string
17
+ issue-link :
18
+ description : ' Issue link in format https://github.com/wazuh/<REPO>/issues/<ISSUE-NUMBER>'
19
+ required : true
20
+ type : string
21
+ id :
22
+ description : ' Optional identifier for the run'
23
+ required : false
24
+ type : string
25
+
26
+ jobs :
27
+ bump :
28
+ name : Repository bumper
29
+ runs-on : ubuntu-22.04
30
+ permissions :
31
+ contents : write
32
+ pull-requests : write
33
+
34
+ env :
35
+ CI_COMMIT_AUTHOR : wazuhci
36
+ CI_COMMIT_EMAIL :
[email protected]
37
+ CI_GPG_PRIVATE_KEY : ${{ secrets.CI_WAZUHCI_GPG_PRIVATE }}
38
+ GH_TOKEN : ${{ secrets.CI_WAZUHCI_BUMPER_TOKEN }}
39
+ BUMP_SCRIPT_PATH : tools/repository_bumper.sh
40
+ BUMP_LOG_PATH : tools/
41
+
42
+ steps :
43
+ - name : Dump event payload
44
+ run : |
45
+ cat $GITHUB_EVENT_PATH | jq '.inputs'
46
+
47
+ - name : Set up GPG key
48
+ id : signing_setup
49
+ run : |
50
+ echo "${{ env.CI_GPG_PRIVATE_KEY }}" | gpg --batch --import
51
+ KEY_ID=$(gpg --list-secret-keys --with-colons | awk -F: '/^sec/ {print $5; exit}')
52
+ echo "gpg_key_id=$KEY_ID" >> $GITHUB_OUTPUT
53
+
54
+ - name : Set up git
55
+ run : |
56
+ git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
57
+ git config --global user.email "${{ env.CI_COMMIT_EMAIL }}"
58
+ git config --global commit.gpgsign true
59
+ git config --global user.signingkey "${{ steps.signing_setup.outputs.gpg_key_id }}"
60
+ echo "use-agent" >> ~/.gnupg/gpg.conf
61
+ echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
62
+ echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
63
+ echo RELOADAGENT | gpg-connect-agent
64
+ export DEBIAN_FRONTEND=noninteractive
65
+ export GPG_TTY=$(tty)
66
+
67
+ - name : Checkout repository
68
+ uses : actions/checkout@v4
69
+ with :
70
+ # Using workflow-specific GITHUB_TOKEN because currently CI_WAZUHCI_BUMPER_TOKEN
71
+ # doesn't have all the necessary permissions
72
+ token : ${{ secrets.GITHUB_TOKEN }}
73
+
74
+ - name : Determine branch name
75
+ id : vars
76
+ env :
77
+ VERSION : ${{ inputs.version }}
78
+ STAGE : ${{ inputs.stage }}
79
+ run : |
80
+ script_params=""
81
+ version=${{ env.VERSION }}
82
+ stage=${{ env.STAGE }}
83
+
84
+ # Both version and stage provided
85
+ if [[ -n "$version" && -n "$stage" ]]; then
86
+ script_params="--version ${version} --stage ${stage}"
87
+ elif [[ -z "$version" && -n "$stage" ]]; then
88
+ script_params="--stage ${stage}"
89
+ fi
90
+
91
+ issue_number=$(echo "${{ inputs.issue-link }}" | awk -F'/' '{print $NF}')
92
+ BRANCH_NAME="enhancement/wqa${issue_number}-bump-${{ github.ref_name }}"
93
+ echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
94
+ echo "script_params=${script_params}" >> $GITHUB_OUTPUT
95
+
96
+ - name : Create and switch to bump branch
97
+ run : |
98
+ git checkout -b ${{ steps.vars.outputs.branch_name }}
99
+
100
+ - name : Make version bump changes
101
+ run : |
102
+ echo "Running bump script"
103
+ bash ${{ env.BUMP_SCRIPT_PATH }} ${{ steps.vars.outputs.script_params }}
104
+
105
+ - name : Commit and push changes
106
+ run : |
107
+ git add .
108
+ git commit -m "feat: bump ${{ github.ref_name }}"
109
+ git push origin ${{ steps.vars.outputs.branch_name }}
110
+
111
+ - name : Create pull request
112
+ id : create_pr
113
+ run : |
114
+ gh auth setup-git
115
+ PR_URL=$(gh pr create \
116
+ --title "Bump ${{ github.ref_name }} branch" \
117
+ --body "Issue: ${{ inputs.issue-link }}" \
118
+ --base ${{ github.ref_name }} \
119
+ --head ${{ steps.vars.outputs.branch_name }})
120
+
121
+ echo "Pull request created: ${PR_URL}"
122
+ echo "pull_request_url=${PR_URL}" >> $GITHUB_OUTPUT
123
+
124
+ - name : Merge pull request
125
+ run : |
126
+ # Any checks for the PR are bypassed since the branch is expected to be functional (i.e. the bump process does not introduce any bugs)
127
+ gh pr merge "${{ steps.create_pr.outputs.pull_request_url }}" --merge
128
+
129
+ - name : Show logs
130
+ run : |
131
+ echo "Bump complete."
132
+ echo "Branch: ${{ steps.vars.outputs.branch_name }}"
133
+ echo "PR: https://github.com/${{ github.repository }}/pull/${{ steps.create_pr.outputs.pull_request_number }}"
134
+ echo "Bumper scripts logs:"
135
+ cat ${BUMP_LOG_PATH}/repository_bumper*log
0 commit comments