-
Notifications
You must be signed in to change notification settings - Fork 123
123 lines (108 loc) · 4.45 KB
/
release.yml
File metadata and controls
123 lines (108 loc) · 4.45 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: Create Release
on:
workflow_run:
workflows: ["Build"]
types:
- completed
branches:
- main
workflow_dispatch:
inputs:
workflow_run_id:
description: 'Workflow Run ID to use for artifacts'
required: true
type: string
env:
MAJOR_VERSION: "1"
MINOR_VERSION: "3"
CURRENT_RELEASE: "1.2"
jobs:
release:
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: "*"
path: artifacts
run-id: ${{ github.event.workflow_run.id || inputs.workflow_run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare app artifacts
run: |
cd artifacts
# Create zip for Windows app
cd PS5-NOR-Modifier-win-x64
zip -r PS5-NOR-Modifier-win-x64.zip .
- name: Calculate next version
id: version
run: |
# Get the base version
BASE_VERSION="${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}"
# Fetch all tags
git fetch --tags
# Get count of existing tags that match our base version
TAG_COUNT=$(git tag -l "v${BASE_VERSION}.*" | wc -l)
# Use tag count as patch version
PATCH_VERSION="$TAG_COUNT"
# Set the full version
FULL_VERSION="v${BASE_VERSION}.${PATCH_VERSION}"
echo "new_tag=${FULL_VERSION}" >> $GITHUB_OUTPUT
# Generate changelog
# Get all version tags and sort them, excluding the current version and anything newer
PREV_TAG=$(git tag -l "v*.*.*" | sort -V | while read tag; do
# Only keep tags that are strictly less than our new version
if [ "$(echo -e "${FULL_VERSION}\n${tag}" | sort -V | head -n1)" = "${tag}" ] && [ "${tag}" != "${FULL_VERSION}" ]; then
echo "$tag"
fi
done | tail -n1 || echo "")
if [ -z "$PREV_TAG" ]; then
# If no previous tag, use all commits
CHANGELOG=$(git log --pretty=format:"* %s" || echo "Initial release")
else
# Get commits since last tag
CHANGELOG=$(git log --pretty=format:"* %s" ${PREV_TAG}..HEAD || echo "No changes")
fi
{
echo "changelog<<EOF"
echo "## What's Changed"
echo "${CHANGELOG}"
echo "## How to use"
echo "This section is still a WIP, I will update it once I am able to better test out the execution of the files we are generating."
echo "### Windows"
echo "After downloading the windows binary, you should just be able to run the executable and after allowing it to run, you should be able to use it."
echo "### MacOS"
echo "After downloading the macos binary, unblock the executable, see image bellow for how to find it. Just hit `Open Anyways` and follow prompts"
echo ""
echo ""
echo ""
echo "### Linux"
echo "Theoretically this works on all x86_64 linux distros, if you have any issues please let me know."
echo ""
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Calculate version status
id: version_status
run: |
BASE_VERSION="${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}"
IS_PRERELEASE=$([ "$BASE_VERSION" != "${{ env.CURRENT_RELEASE }}" ] && echo "true" || echo "false")
echo "is_prerelease=${IS_PRERELEASE}" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.new_tag }}
name: Release ${{ steps.version.outputs.new_tag }}
body: ${{ steps.version.outputs.changelog }}
files: |
artifacts/**/*.tar.gz
artifacts/**/*.zip
artifacts/UART-CL-win-x64/UART-CL By TheCod3r.exe
draft: ${{ steps.version_status.outputs.is_prerelease == 'false' }}
prerelease: ${{ steps.version_status.outputs.is_prerelease == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}