-
Notifications
You must be signed in to change notification settings - Fork 4
57 lines (52 loc) · 1.72 KB
/
version.yml
File metadata and controls
57 lines (52 loc) · 1.72 KB
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
name: Git Versioning
on:
push:
branches:
- main
workflow_dispatch:
inputs:
version:
description: 'The version of the project'
required: true
jobs:
version:
name: Tag version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{secrets.GH_PAT}}
submodules: true
- name: Generate tag version
run: |
echo "project_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | tr -d '\n')" >> $GITHUB_ENV
- name: Create tag
uses: actions/github-script@v7
with:
script: |
const { project_version } = process.env
const new_version = '${{ github.event.inputs.version }}'
const sha_substring = context.sha.substring(0, 7);
const version = new_version ? new_version : project_version
const version_sha = `${version}-${sha_substring}`
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/v${version_sha}`,
sha: context.sha
}).catch(err => {
if (err.status !== 422) throw err;
github.rest.git.updateRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/v${{version_sha}}',
sha: context.sha
});
})
github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: `v${version_sha}`,
name: `v${version_sha}`,
generate_release_notes: true
})