forked from Fusion-Power-Plant-Framework/bluemira
-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (76 loc) · 2.73 KB
/
release.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
# This workflow creates a new release from the HEAD of the 'develop' branch.
# The branch is merged into 'main' and a release is created using the version
# number that was inputted when the workflow was triggered.
# Once the release is created, a PR to merge 'develop_dependencies'->'develop'
# is created, this reminds us to update our dependencies for the next
# development cycle.
name: Make Release
on:
workflow_dispatch:
inputs:
version:
type: string
description: "New semantic version string"
required: true
draft:
type: boolean
description: "Create draft release"
default: false
open_dependencies_pr:
type: boolean
default: false
jobs:
release:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.FPPF_BOT_AUTH_KEY }}
- name: Permissions Check
uses: ./.github/workflows/actions/permission_check
with:
token: ${{ secrets.FPPF_BOT_AUTH_KEY }}
- name: Validate
id: validate
run: |
# Check, and format, input version
pip install packaging
VERSION="$(python -c "from packaging import version; print(version.Version(\"${{ github.event.inputs.version }}\"))")"
TAG="v${VERSION}"
# Check the tag doesn't already exist
if gh release view "${TAG}" &> /dev/null; then
echo "Release with tag '${TAG}' already exists.";
exit 1;
fi
echo tag=${TAG} >> $GITHUB_OUTPUT
- name: Update main
id: update-main
run: |
git config user.email "107038218+fppf-bot@users.noreply.github.com"
git config user.name "fppf-bot"
git fetch origin main
git checkout main
# The 'Checkout' action performs a shallow checkout of develop.
# We need the history in order to do the merge with main.
git fetch origin develop --unshallow
git merge origin/develop --ff-only
git push origin main:main
- name: Create release
id: create-release
env:
GITHUB_TOKEN: ${{ secrets.FPPF_BOT_AUTH_KEY }}
DRAFT: ${{ inputs.draft && '--draft' || '' }}
run: |
gh release create "${{ steps.validate.outputs.tag }}" \
--generate-notes \
--target main \
${DRAFT}
- name: Open develop_dependencies PR
if: ${{ inputs.open_dependencies_pr && !inputs.draft }}
uses: ./.github/workflows/actions/dependencies_PR
with:
token: ${{ secrets.FPPF_BOT_AUTH_KEY }}
tag: ${{ steps.validate.outputs.tag }}