22# SPDX-FileCopyrightText: (c) 2025 ale5000
33# SPDX-License-Identifier: GPL-3.0-or-later
44
5- name : " - Create tag now "
5+ name : " 1) Tag and release "
66permissions : {}
77on :
88 workflow_dispatch :
9- concurrency :
10- group : " ${{ github.repository_id }}-${{ github.workflow }}"
11- cancel-in-progress : true
9+
1210jobs :
13- tag-creation :
14- name : " Tag creation "
11+ create-tag :
12+ name : " Create tag "
1513 runs-on : ubuntu-latest
1614 timeout-minutes : 10
17- if : " ${{ ! startsWith(github.ref, 'refs/tags/') }}"
15+ if : " ${{ github.ref_type == 'branch' }}"
16+ concurrency :
17+ group : " ${{ github.repository_id }}-${{ github.workflow }}-tag"
18+ cancel-in-progress : true
19+ outputs :
20+ tag-name : " ${{ steps.repo-info.outputs.version }}"
1821 permissions :
1922 contents : write # Needed to create a tag
20- actions : write # Needed to trigger a workflow
2123
2224 steps :
2325 - name : " Checkout sources"
@@ -27,37 +29,44 @@ jobs:
2729 shell : bash
2830 run : |
2931 # Parsing version...
30- version="$(grep -m 1 -e '^version=' -- 'zip-content/module.prop' | cut -d '=' -f '2-' -s)" || exit "${?}"
31- printf 'version=%s\n' "${version:?}" >> "${GITHUB_OUTPUT?}" || exit "${?}"
32+ version="$(grep -m 1 -e '^version=' -- './ zip-content/module.prop' | cut -d '=' -f '2-' -s)" || exit "${?}"
33+ printf 'version=%s\n' "${version:?}" 1 >> "${GITHUB_OUTPUT?}" || exit "${?}"
3234 - name : " Create tag"
3335 uses : actions/github-script@v7
36+ timeout-minutes : 5
37+ env :
38+ TAG_NAME : " ${{ steps.repo-info.outputs.version }}"
3439 with :
3540 retries : 3
3641 script : |
3742 /* jshint esversion: 6 */
38- console.log('::notice::Tag name: ${{ steps.repo-info.outputs.version }}');
43+ const tag_name = process.env.TAG_NAME;
44+ console.log('::notice::Tag: ' + tag_name);
3945 const response = await github.rest.git.createRef({
4046 owner: context.repo.owner,
4147 repo: context.repo.repo,
42- ref: 'refs/tags/${{ steps.repo-info.outputs.version }}' ,
48+ ref: 'refs/tags/' + tag_name ,
4349 sha: context.sha
44- }).catch(error => {
45- if(error.status === 422 && error.message === 'Reference already exists') {
46- console.warn('::warning::Tag already exist, ignored!!!');
47- return;
48- }
49- console.error('::error::Tag creation failed with error: ' + error.status);
50- console.error('::error::Error message: ' + error.message);
51- console.log('');
52- throw error;
53- });
54- if(response && response.status >= 200 && response.status < 300) {
55- console.log('');
56- console.log('Triggered the workflow for the release.');
57- github.rest.actions.createWorkflowDispatch({
58- owner: context.repo.owner,
59- repo: context.repo.repo,
60- workflow_id: 'auto-release-from-tag.yml',
61- ref: 'refs/tags/${{ steps.repo-info.outputs.version }}'
62- });
50+ }).catch(response => response);
51+ if(response && response.status === 201) {
52+ console.log('Tag created.');
53+ return true;
54+ } else if(response && response.status === 422 && response.message === 'Reference already exists') {
55+ //console.warn('::warning::Tag already exist!!!');
56+ throw new Error('Tag already exist!!!');
57+ } else {
58+ let errorMsg = 'createRef failed';
59+ if(response && response.status && response.message) errorMsg += ' with error ' + response.status + ' (' + response.message + ')';
60+ throw new Error(errorMsg);
6361 }
62+ return false;
63+
64+ call-workflow :
65+ name : " Call workflow"
66+ needs : [create-tag]
67+ if : " ${{ github.ref_type == 'branch' }}"
68+ uses : " ./.github/workflows/auto-release-from-tag.yml"
69+ with :
70+ tag-name : " ${{ needs.create-tag.outputs.tag-name }}"
71+ permissions :
72+ contents : write # Needed to create a release
0 commit comments