-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a workflow to build the ISO and trigger release
- Loading branch information
1 parent
e954d9a
commit ef9c10e
Showing
4 changed files
with
134 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
name: Create Release on Version Update | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
|
||
jobs: | ||
create-release: | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Compare current release with VERSION file | ||
id: compare_versions | ||
run: | | ||
if [ "$(gh release view -q '.tagName' --json tagName)" == "$(cat VERSION)" ]; then | ||
echo "No new release to generate!" | ||
echo "NEW_RELEASE=0" >> $GITHUB_ENV | ||
exit | ||
fi | ||
# Apparently the tag still exists when the release is deleted from GitHub web interface... | ||
# Also mock the exit status so that it always returns with code 0. | ||
git push --delete origin refs/tags/$(cat VERSION) || true | ||
echo "NEW_RELEASE=1" >> $GITHUB_ENV | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Install dependencies | ||
id: install_depends | ||
run: | | ||
sudo add-apt-repository universe | ||
sudo apt update | ||
sudo apt-get install -y xorriso | ||
- name: Build ISO | ||
id: build_iso | ||
if: ${{ env.NEW_RELEASE == '1' }} | ||
run: | | ||
files="$(cat FILES.txt | tr '\n' ' ')" | ||
xorriso -as mkisofs -r -J --joliet-long -V 'STDU_GH' -o STDU-GH.iso -partition_offset 16 $(files) | ||
- name: Run catalog script | ||
id: run_script | ||
if: ${{ env.NEW_RELEASE == '1' }} | ||
run: | | ||
# Execute the script and save the output | ||
if [ -x scripts/GetCatalog.sh ]; then | ||
GH_TOKEN=$GH_TOKEN ./scripts/GetCatalog.sh > release_notes.md | ||
else | ||
echo "scripts/GetCatalog.sh is not executable or not found" | ||
exit 1 | ||
fi | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create tag | ||
id: create_tag | ||
if: ${{ env.NEW_RELEASE == '1' }} | ||
run: | | ||
# Generate a new tag based on the version | ||
TAG_NAME=$(cat VERSION) | ||
git tag $TAG_NAME | ||
git push origin $TAG_NAME | ||
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV | ||
- name: Output release notes | ||
id: output_release_notes | ||
if: ${{ env.NEW_RELEASE == '1' }} | ||
run: | | ||
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV | ||
cat release_notes.md >> $GITHUB_ENV | ||
echo "EOF" >> $GITHUB_ENV | ||
- name: Create release | ||
if: ${{ env.NEW_RELEASE == '1' }} | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
tag_name: ${{ env.TAG_NAME }} | ||
release_name: ${{ env.TAG_NAME }} # No "Release" prefix here | ||
body: ${{ env.RELEASE_NOTES }} | ||
draft: false | ||
prerelease: false | ||
files: STDU-GH.iso | ||
fail_on_unmatched_files: true | ||
make_latest: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.0.0-24H2 | ||
v1.0.0-24H2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
# Read the current version from the VERSION file and create the header | ||
VERSION=$(sed 's/^v//' VERSION) | ||
VERSION_HEADER="Version $VERSION" | ||
|
||
# Define the path to the CHANGELOG.md file | ||
CHANGELOG_FILE="CHANGELOG.mkdn" | ||
|
||
# Get the remote origin URL from git | ||
REMOTE_URL=$(gh repo view -q '.url' --json url) | ||
|
||
# Parse the website, owner, and repo from the remote URL | ||
website=$(echo "$REMOTE_URL" | sed -n 's|.*\(https://[^/]*\).*|\1|p') | ||
owner=$(gh repo view -q '.owner.login' --json owner) | ||
repo=$(gh repo view -q '.name' --json name) | ||
|
||
# Find the previous version by looking for the first version header that comes before the current version header | ||
# | ||
# NO you do NOT have to do it this way while GitHub-CLI is at your disposal, Diana. - Spring | ||
#PREV_VERSION=$(awk -v header="$VERSION_HEADER" ' | ||
# BEGIN {found=0} | ||
# $0 == header {found=1; next} | ||
# /^Version/ && found {print; exit} | ||
#' "$CHANGELOG_FILE" | sed 's/^Version //') | ||
|
||
# Much cleaner and oneliner, you only need to set GH_TOKEN in Actions environment, which I did for you. | ||
PREV_VERSION=$(gh release view -q '.tagName' --json tagName | sed 's/^V//') | ||
|
||
# Extract the content between the specified version and the next version, excluding the release URL and dashes | ||
awk -v header="$VERSION_HEADER" -v website="$website" -v owner="$owner" -v repo="$repo" ' | ||
BEGIN {found=0} | ||
$0 == header {found=1; next} | ||
/^Version/ && found {exit} | ||
found && !($0 ~ website owner repo "/releases/tag/v.*" && $0 ~ /[0-9]+\.[0-9]+/) && !/^-----.*/ {print} | ||
' "$CHANGELOG_FILE" | ||
|
||
# Add the "Full Changelog" line comparing the previous version with the current one only if a previous version exists | ||
if [[ -n "$PREV_VERSION" ]]; then | ||
echo "**Full Changelog**: $REMOTE_URL/compare/V$PREV_VERSION...V$VERSION" | ||
fi |