Repository navigation
85 lines (75 loc) · 2.74 KB
/
Copy path_version.yml
File metadata and controls
85 lines (75 loc) · 2.74 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
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: version
on:
workflow_call:
inputs:
harden-runner-policy:
description: "The egress policy for the Harden Runner step. Defaults to 'block'"
required: false
type: string
default: "block"
version-artifact-name:
description: "Name of the artifact to put the version file in"
required: false
type: string
default: "version"
is-release-branch:
description: 'If its a release branch or not. eg release from main check would be "github.ref==''refs/heads/main''" '
type: boolean
required: true
outputs:
version:
description: The new version number
value: ${{ jobs.find-version.outputs.version }}
current-version:
description: The current version number
value: ${{ jobs.find-version.outputs.current-version }}
permissions:
contents: read
jobs:
find-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
current-version: ${{ steps.get-version.outputs.current-version }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
disable-sudo: true
egress-policy: ${{ inputs.harden-runner-policy }}
allowed-endpoints: >
github.com:443
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Determine release branch name
id: release-branch
run: |
release_branch="main"
if [ "${GITHUB_REF_NAME}" = "main" ] && [ "${{ inputs.is-release-branch }}" != "true" ]; then
release_branch="not-main-release"
fi
echo "release-branch-name=$release_branch" >> $GITHUB_OUTPUT
echo "Release branch name set to: $release_branch"
- name: Get version
uses: reecetech/version-increment@a29aa752dc3b8118a2dc2ed93faf0e95a73a9c7e # 2024.10.1
id: get-version
with:
scheme: conventional_commits
increment: patch
release_branch: ${{ steps.release-branch.outputs.release-branch-name }}
- name: Current version
run: echo "${{ steps.get-version.outputs.current-version }}"
- name: New version
id: write_version
run: |
VERSION="${{ steps.get-version.outputs.version }}"
echo "New version: $VERSION"
echo "$VERSION" > version.txt
- name: Upload artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ inputs.version-artifact-name }}
path: version.txt
if-no-files-found: error