Repository navigation
98 lines (85 loc) · 3.36 KB
/
Copy pathrelease.yml
File metadata and controls
98 lines (85 loc) · 3.36 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
86
87
88
89
90
91
92
93
94
95
96
97
98
name: manual release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release'
required: true
force_delete:
description: 'Force delete existing tags'
type: boolean
default: false
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# Version commits and framework tag pushes authenticate through origin.
persist-credentials: true
- name: Remove optional "v" prefix
id: version
run: |
echo "version=${VERSION#v}" >> "$GITHUB_OUTPUT"
env:
VERSION: ${{ inputs.version }}
- name: Check if branch and version match
id: guard
run: |
MAJOR_VERSION="${NUMERIC_VERSION%%.*}"
BRANCH_MAJOR_VERSION="${BRANCH%%.*}"
if [ "$MAJOR_VERSION" != "$BRANCH_MAJOR_VERSION" ]; then
echo "Mismatched versions! Aborting."
VERSION_MISMATCH='true';
else
echo "Versions match! Proceeding."
VERSION_MISMATCH='false';
fi
echo "VERSION_MISMATCH=$(echo $VERSION_MISMATCH)" >> "$GITHUB_OUTPUT";
env:
BRANCH: ${{ github.ref_name }}
NUMERIC_VERSION: ${{ steps.version.outputs.version }}
- name: Fail if branch and release tag do not match
if: ${{ steps.guard.outputs.VERSION_MISMATCH == 'true' }}
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
core.setFailed('Workflow failed. Release version does not match with selected target branch. Did you select the correct branch?')
- name: Update Application.php version
run: |
sed -i "s/const string VERSION = '.*';/const string VERSION = '${VERSION}';/g" src/foundation/src/Application.php
grep -Fq -- "const string VERSION = '${VERSION}';" src/foundation/src/Application.php
env:
VERSION: ${{ steps.version.outputs.version }}
- name: Commit version change
uses: stefanzweifel/git-auto-commit-action@4a55954c782fc1ea30b9056cd3e7a2b40ca8887d # v7.2.0
with:
commit_message: "Update version to v${{ steps.version.outputs.version }}"
- name: Setup private key
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
echo "StrictHostKeyChecking no" >> ~/.ssh/config
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Split and push
run: |
git config pull.rebase true
git config --global user.email "albert@hypervel.org"
git config --global user.name "Hypervel"
if [ ${{ inputs.force_delete }} = true ]; then
bash ./bin/release.sh v${{ steps.version.outputs.version }} -f
else
bash ./bin/release.sh v${{ steps.version.outputs.version }}
fi
- name: Create release notes
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
with:
generate_release_notes: true
name: v${{ steps.version.outputs.version }}
tag_name: v${{ steps.version.outputs.version }}