Skip to content

Commit 009972a

Browse files
committed
Refactor prepare job into a reusable workflow
1 parent 777f917 commit 009972a

File tree

2 files changed

+58
-37
lines changed

2 files changed

+58
-37
lines changed

.github/workflows/prepare-release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Prepare release
2+
on:
3+
workflow_call:
4+
push:
5+
paths:
6+
- .github/workflows/prepare-release.yml
7+
8+
jobs:
9+
prepare:
10+
name: "Prepare release"
11+
runs-on: ubuntu-latest
12+
if: github.repository == 'github/codeql-action'
13+
14+
permissions:
15+
contents: read
16+
17+
outputs:
18+
version: ${{ steps.versions.outputs.version }}
19+
major_version: ${{ steps.versions.outputs.major_version }}
20+
latest_tag: ${{ steps.versions.outputs.latest_tag }}
21+
backport_source_branch: ${{ steps.branches.outputs.backport_source_branch }}
22+
backport_target_branches: ${{ steps.branches.outputs.backport_target_branches }}
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v5
27+
with:
28+
fetch-depth: 0 # Need full history for calculation of diffs
29+
30+
- name: Configure runner for release
31+
uses: ./.github/actions/release-initialise
32+
33+
- name: Get version tags
34+
id: versions
35+
run: |
36+
VERSION="v$(jq '.version' -r 'package.json')"
37+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
38+
MAJOR_VERSION=$(cut -d '.' -f1 <<< "${VERSION}")
39+
echo "major_version=${MAJOR_VERSION}" >> $GITHUB_OUTPUT
40+
LATEST_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | head -1)
41+
echo "latest_tag=${LATEST_TAG}" >> $GITHUB_OUTPUT
42+
43+
- name: Determine older release branches
44+
id: branches
45+
uses: ./.github/actions/release-branches
46+
with:
47+
major_version: ${{ steps.versions.outputs.major_version }}
48+
latest_tag: ${{ steps.versions.outputs.latest_tag }}
49+
50+
- name: Print release information
51+
run: |
52+
echo 'version: ${{ steps.versions.outputs.version }}'
53+
echo 'major_version: ${{ steps.versions.outputs.major_version }}'
54+
echo 'latest_tag: ${{ steps.versions.outputs.latest_tag }}'
55+
echo 'backport_source_branch: ${{ steps.branches.outputs.backport_source_branch }}'
56+
echo 'backport_target_branches: ${{ steps.branches.outputs.backport_target_branches }}'

.github/workflows/update-release-branch.yml

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,11 @@ on:
1414
jobs:
1515

1616
prepare:
17-
runs-on: ubuntu-latest
18-
if: github.repository == 'github/codeql-action'
19-
outputs:
20-
version: ${{ steps.versions.outputs.version }}
21-
major_version: ${{ steps.versions.outputs.major_version }}
22-
latest_tag: ${{ steps.versions.outputs.latest_tag }}
23-
backport_source_branch: ${{ steps.branches.outputs.backport_source_branch }}
24-
backport_target_branches: ${{ steps.branches.outputs.backport_target_branches }}
17+
name: "Prepare release"
2518
permissions:
2619
contents: read
27-
steps:
28-
- uses: actions/checkout@v5
29-
with:
30-
fetch-depth: 0 # Need full history for calculation of diffs
31-
- uses: ./.github/actions/release-initialise
3220

33-
- name: Get version tags
34-
id: versions
35-
run: |
36-
VERSION="v$(jq '.version' -r 'package.json')"
37-
echo "version=${VERSION}" >> $GITHUB_OUTPUT
38-
MAJOR_VERSION=$(cut -d '.' -f1 <<< "${VERSION}")
39-
echo "major_version=${MAJOR_VERSION}" >> $GITHUB_OUTPUT
40-
LATEST_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | head -1)
41-
echo "latest_tag=${LATEST_TAG}" >> $GITHUB_OUTPUT
42-
43-
- id: branches
44-
name: Determine older release branches
45-
uses: ./.github/actions/release-branches
46-
with:
47-
major_version: ${{ steps.versions.outputs.major_version }}
48-
latest_tag: ${{ steps.versions.outputs.latest_tag }}
49-
50-
- name: debug logging
51-
run: |
52-
echo 'version: ${{ steps.versions.outputs.version }}'
53-
echo 'major_version: ${{ steps.versions.outputs.major_version }}'
54-
echo 'latest_tag: ${{ steps.versions.outputs.latest_tag }}'
55-
echo 'backport_source_branch: ${{ steps.branches.outputs.backport_source_branch }}'
56-
echo 'backport_target_branches: ${{ steps.branches.outputs.backport_target_branches }}'
21+
uses: .github/workflows/prepare-release.yml
5722

5823
update:
5924
timeout-minutes: 45

0 commit comments

Comments
 (0)