-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (84 loc) · 2.92 KB
/
shared-ext-release-workflow.yml
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
86
87
88
89
90
91
92
93
94
95
# This workflow is manged centrally in CommonTooling
name: Shared Release Workflow
on:
workflow_call:
inputs:
commontoolingBranch:
description: 'Commontooling branch or tag to use'
required: true
default: 'main'
type: string
outputs:
releaseRef:
description: "The tag ref of the created release"
value: ${{ jobs.Release.outputs.releaseRef }}
secrets:
COMMONTOOLING_DEPLOY_KEY:
description: 'A deploy key that may be used to fetch Commontooling'
required: true
env:
COMMONTOOLING_BRANCH: ${{ inputs.commontoolingBranch == '' && 'main' || inputs.commontoolingBranch }}
jobs:
CheckStaticFiles:
name: Check Static Files
permissions:
contents: read
runs-on: ubuntu-22.04
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Initialise commontooling
uses: actions/checkout@v4
with:
repository: bbc/rd-cloudfit-commontooling
ref: ${{ env.COMMONTOOLING_BRANCH }}
path: commontooling
fetch-depth: 1
ssh-key: ${{ secrets.COMMONTOOLING_DEPLOY_KEY }}
- name: Check static files
run: make check-static-files
Release:
permissions:
contents: write
runs-on: ubuntu-22.04
needs: CheckStaticFiles
environment:
name: releases
url: ${{ steps.release.outputs.url }}
outputs:
releaseRef: refs/tags/${{ steps.nextVersion.outputs.version }}
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0 # check out entire repo for version calculation
- name: Get next version number
id: nextVersion
run: echo "version=$(make next-version)" >> $GITHUB_OUTPUT
- name: Create tag
run: |
git config --global user.email "[email protected]"
git config --global user.name "BBC RD"
git tag -a ${{ steps.nextVersion.outputs.version }} -m "v.${{ steps.nextVersion.outputs.version }}"
git push origin --tags
- name: Create release
id: release
uses: actions/github-script@v7
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
try {
const response = await github.rest.repos.createRelease({
generate_release_notes: true,
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: '${{ steps.nextVersion.outputs.version }}'
});
core.setOutput('url', response.data.html_url);
} catch (error) {
core.setFailed(error.message);
}
- name: Adding summary
run: |
echo "Release Version: ${{ steps.nextVersion.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "Release URL: ${{ steps.release.outputs.url }}" >> $GITHUB_STEP_SUMMARY