Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Automate release process #51

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -24,9 +25,10 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. Windows/OSX/LINUX]
- Running via binary or npm start
- Version [e.g. v0.0.3-alpa]

- OS: [e.g. Windows/OSX/LINUX]
- Running via binary or npm start
- Version [e.g. v0.0.3-alpa]

**Additional context**
Add any other context about the problem here.
6 changes: 4 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ assignees: whitewhidow
---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
A clear and concise description of what the problem is. Ex. I'm always
frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
A clear and concise description of any alternative solutions or features you've
considered.

**Additional context**
Add any other context or screenshots about the feature request here.
174 changes: 174 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# This workflow runs on every new tag created, and builds the app for 3 platforms (mac, windows, linux).
# It also creates a new release on the repo's Release page, and uploads the artifacts to there.
#
# Usage:
# git commit -m "Release v0.9.2"
# git push origin v0.9.2
run-name: Build & Release

on:
push:
tags:
- 'v*'

jobs:
release:
name: ${{ matrix.os == 'macos-latest' && 'Mac' || 'Linux' }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest]

steps:
- name: Check out Git repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Get semver string
id: semver_parser
uses: booxmedialtd/ws-action-parse-semver@v1
with:
version_extractor_regex: 'v(.*)'
input_string: ${{ github.ref_name }}

- name: Get previous tag
run: |
PREVTAG=$(git describe --abbrev=0 --tags "${{ github.ref }}^")
echo "PREVTAG=$PREVTAG" >> $GITHUB_ENV

- name: Get version from package.json
run: |
echo PKGJSONVERSION=$(jq -r '.version' package.json) >> $GITHUB_ENV

- name: Version check
run: |
if [ "${{ env.PKGJSONVERSION }}" != "${{ steps.semver_parser.outputs.fullversion }}" ]; then
echo "Version mismatch: \"${{ env.PKGJSONVERSION }}\" != \""${{ steps.semver_parser.outputs.fullversion }}"\""
echo "You need to update the version number in package.json"
exit 1
fi

- name: Generate Changelog Body
if: matrix.os == 'macos-latest'
run: |
echo -e "# Sidenoder \`${{ github.ref_name }}\`" > changelog-body.md

git log ${{env.PREVTAG}}..HEAD^1 --pretty=format:"%s" | sort -f | while read line; do
line="$(tr '[:lower:]' '[:upper:]' <<< ${line:0:1})${line:1}"

case $line in
[Ff]eat*)
line=$(echo $line | sed -E "s/^[Ff]eat\(?.*\)?: //")
echo "- $line" >> commits-feat;;
[Ff]ix*)
line=$(echo $line | sed -E "s/^[Ff]ix\(?.*\)?: //")
echo "- $line" >> commits-fix;;
[Pp]erf*)
line=$(echo $line | sed -E "s/^[Pp]erf\(?.*\)?: //")
echo "- $line" >> commits-perf;;
[Ss]tyle*)
line=$(echo $line | sed -E "s/^[Ss]tyle\(?.*\)?: //")
echo "- $line" >> commits-style;;
[Mm]erge*)
# Skip merge commits
;;
*)
echo "- $line" >> commits-other;;
esac
done

if [ -s commits-feat ]; then
echo -e "\n## New Features\n\n$(cat commits-feat)" > commits-feat
cat commits-feat >> changelog-body.md
fi

if [ -s commits-fix ]; then
echo -e "\n## Fixes\n\n$(cat commits-fix)" > commits-fix
cat commits-fix >> changelog-body.md
fi

if [ -s commits-perf ]; then
echo -e "\n## Performance Improvements\n\n$(cat commits-perf)" > commits-perf
cat commits-perf >> changelog-body.md
fi

if [ -s commits-style ]; then
echo -e "\n## Style Changes\n\n$(cat commits-style)" > commits-style
cat commits-style >> changelog-body.md
fi

if [ -s commits-other ]; then
echo -e "\n## Other Changes\n\n$(cat commits-other)" > commits-other
cat commits-other >> changelog-body.md
fi

echo -e "\n---\n\n" >> changelog-body.md
echo -e "### View the full changelog [here](https://github.com/MikeRatcliffe/sidenoder/compare/${{env.PREVTAG}}...${{ github.ref_name }})." >> changelog-body.md

- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v4
with:
node-version: 22.x

- name: Clobber And Install Dependencies
run: |
npm run clobber
npm install

- name: Build (Mac)
if: matrix.os == 'macos-latest'
run: |
npm run dist-mac
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install Wine (Windows)
if: matrix.os == 'ubuntu-latest'
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install wine32 wine64

- name: Build (Windows & Linux)
if: matrix.os == 'ubuntu-latest'
run: npm run dist-win-linux
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Push Build To Releases (Mac)
if: matrix.os == 'macos-latest'
uses: ncipollo/release-action@v1
with:
tag: v${{ steps.semver_parser.outputs.fullversion }}
allowUpdates: true
artifactErrorsFailBuild: true
bodyFile: changelog-body.md
generateReleaseNotes: false
makeLatest: false
prerelease: ${{ steps.semver_parser.outputs.prerelease != ''}}
replacesArtifacts: false
artifacts: /tmp/out/sidenoder*.dmg
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Push Builds To Releases (Windows & Linux)
if: matrix.os == 'ubuntu-latest'
uses: ncipollo/release-action@v1
with:
tag: v${{ steps.semver_parser.outputs.fullversion }}
allowUpdates: true
artifactErrorsFailBuild: true
generateReleaseNotes: false
makeLatest: true
omitBody: true
prerelease: ${{ steps.semver_parser.outputs.prerelease != ''}}
replacesArtifacts: false
artifacts: |
/tmp/out/sidenoder*.exe
/tmp/out/sidenoder*.AppImage
/tmp/out/sidenoder*.deb
/tmp/out/sidenoder*.rpm
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55 changes: 0 additions & 55 deletions .github/workflows/main-osx.yml

This file was deleted.

50 changes: 0 additions & 50 deletions .github/workflows/main-win-other.yml

This file was deleted.

49 changes: 0 additions & 49 deletions .github/workflows/main-win.yml

This file was deleted.

Loading