forked from javamachr/quest-sidenoder
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds GitHub Actions workflow for automated releases, including: - Build for multiple OSs: - macOs (Universal `dmg` for both Intel & M1) - Windows `exe` - Linux: - `AppImage` - `deb` - `rpm` - Changelog is automatically generated when a version number tag is added to a commit e.g. `v0.9.2`. This streamlines the release process and ensures consistent releases across all platforms. Usage: 1. Update version number in `package.json`. 2. ``` git commit -m "Release v0.9.2" git tag v0.9.2 # The version number must be in the format `v1.2.3`. git push --force --tags ``` 3. That's it... a release will be automatically generated along with conventional commit messages and installation packages for each platform. To ensure we pick up all changes we should probably add the conventional commits pre-commit hook to ensure commit messages contain the required `fix`, `feat` etc.
- Loading branch information
1 parent
39a1783
commit 3e9b59b
Showing
6 changed files
with
193 additions
and
246 deletions.
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,173 @@ | ||
# 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 tag v0.9.2 | ||
# git push --force --tags | ||
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: npm install | ||
run: 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 }} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.