Skip to content

Commit 7d5df27

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

File tree

2 files changed

+75
-37
lines changed

2 files changed

+75
-37
lines changed

.github/workflows/prepare-release.yml

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