Skip to content

Commit

Permalink
On to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
blopker committed Dec 16, 2024
1 parent bc82f67 commit 4040a3b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 205 deletions.
18 changes: 3 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: "publish"

on:
push:
branches:
- release
tags:
- "v*"

# This workflow will trigger on each push to the `release` branch to create or update a GitHub release, build your app, and upload the artifacts to the release.

Expand All @@ -19,10 +19,6 @@ jobs:
args: "--target aarch64-apple-darwin"
- platform: "macos-latest" # for Intel based macs.
args: "--target x86_64-apple-darwin"
# - platform: "ubuntu-22.04" # for Tauri v1 you could replace this with ubuntu-20.04.
# args: ""
# - platform: "windows-latest"
# args: ""

runs-on: ${{ matrix.platform }}
steps:
Expand All @@ -38,14 +34,6 @@ jobs:
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}

# - name: install dependencies (ubuntu only)
# if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above.
# run: |
# sudo apt-get update
# sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
# # webkitgtk 4.0 is for Tauri v1 - webkitgtk 4.1 is for Tauri v2.
# # You can remove the one that doesn't apply to your app to speed up the workflow a bit.

- name: Rust cache
uses: swatinem/rust-cache@v2
with:
Expand All @@ -60,7 +48,7 @@ jobs:
with:
tagName: alic-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
releaseName: "Alic v__VERSION__"
releaseBody: "See the assets to download this version and install."
releaseBody: "See the assets to download this version and install.\n\n[Changelog](https://github.com/blopker/alic/blob/main/CHANGELOG.md)"
releaseDraft: true
prerelease: false
args: ${{ matrix.args }}
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Unreleased

- Nothing yet

# 2.0.0

- Complete rewrite to use Tauri and SolidJS
Expand Down
10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,5 @@ build_dmg:
open_app_folder:
open ~/Library/Application Support/io.kbl.alic

release_major:
bun run scripts/release.ts major

release_minor:
bun run scripts/release.ts minor

release_patch:
bun run scripts/release.ts patch
release:
bun run scripts/release.ts
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ All compression is done locally on your machine. Alic also does not have any ana
## Roadmap

- [ ] Get the app signed with an Apple Developer ID
- [x] Add a way to check for updates
- [ ] Add a way to check for updates
- [x] Add support for different optimization levels
- [ ] Add support for lossless compression
- [x] Add support for dropping directories
- [ ] Add context menu for opening images in Alic from Finder
- [x] Add context menu for opening images in Alic from Finder
- [x] Add support for resizing images if they are over a certain size

## Built With
Expand Down Expand Up @@ -102,7 +102,7 @@ Don't forget to give the project a star! Thanks again!

To release a new version of Alic, follow these steps:

1. Update the version in `pubspec.yaml`.
1. Update the version in `tauri.conf.json`.
1. Update `CHANGELOG.md`.
1. Commit the changes, but do not push.
1. Run `make release`.
Expand All @@ -121,16 +121,14 @@ This project would not be possible without the following open source projects:

- For compression: [libcaesium][libcaesium-url]
- Original inspiration: [ImageOptim][imageoptim-url]
- Rust interop: [flutter_rust_bridge][flutter-rust-bridge-url]
- UI: [Flutter][flutter-url]
- UI: [Tauri][tauri-url]

[license-url]: https://github.com/blopker/alic/blob/master/LICENSE
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
[linkedin-url]: https://linkedin.com/in/blopker
[product-screenshot]: alic-sc.min.png
[libcaesium-url]: https://github.com/Lymphatus/libcaesium
[flutter-rust-bridge-url]: https://cjycode.com/flutter_rust_bridge/
[flutter-url]: https://flutter.dev/
[tauri-url]: https://tauri.app/
[imageoptim-url]: https://imageoptim.com/mac
[project-url]: https://github.com/blopker/alic
[project-release-url]: https://github.com/blopker/alic/releases
55 changes: 0 additions & 55 deletions scripts/generate-changelog.ts

This file was deleted.

138 changes: 20 additions & 118 deletions scripts/release.ts
Original file line number Diff line number Diff line change
@@ -1,137 +1,39 @@
// scripts/release.ts
import { execSync } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import { $ } from "bun";

function updateChangelog(newVersion: string): void {
const date = new Date().toISOString().split("T")[0];
const changelogPath = "CHANGELOG.md";
const changelog = fs.readFileSync(changelogPath, "utf8");

// Split changelog into lines
const lines = changelog.split("\n");

// Find the Unreleased section
const unreleasedIndex = lines.findIndex((line) =>
line.includes("## Unreleased"),
);
if (unreleasedIndex === -1) {
throw new Error("Could not find Unreleased section in CHANGELOG.md");
}

// Find the next version section
const nextVersionIndex = lines.findIndex(
(line, i) => i > unreleasedIndex && line.startsWith("## ["),
);

// Get unreleased changes
const unreleasedChanges = lines
.slice(
unreleasedIndex + 1,
nextVersionIndex === -1 ? undefined : nextVersionIndex,
)
.filter((line) => line.trim() !== "");

// Create new version section with unreleased changes
const newVersionSection = [
`## [${newVersion}] - ${date}\n`,
...unreleasedChanges,
"\n",
].join("\n");

// Reset unreleased section
const newChangelog = [
"# Changelog",
"",
"## Unreleased",
"",
newVersionSection,
...lines.slice(nextVersionIndex === -1 ? lines.length : nextVersionIndex),
].join("\n");

fs.writeFileSync(changelogPath, newChangelog);
}

function updateVersion(type: "major" | "minor" | "patch") {
function getVersion() {
// Read current version from tauri.conf.json
const tauriConfPath = "src-tauri/tauri.conf.json";
const tauriConf = JSON.parse(fs.readFileSync(tauriConfPath, "utf8"));
const versionMatch = tauriConf.version.match(/(\d+)\.(\d+)\.(\d+)/);

if (!versionMatch) {
throw new Error("Could not find version in tauri.conf.json");
}

let [, major, minor, patch] = versionMatch.map(Number);

// Update version numbers
switch (type) {
case "major":
major++;
minor = 0;
patch = 0;
break;
case "minor":
minor++;
patch = 0;
break;
case "patch":
patch++;
break;
}

const newVersion = `${major}.${minor}.${patch}`;
tauriConf.version = newVersion;
fs.writeFileSync(tauriConfPath, `${JSON.stringify(tauriConf, null, 2)}\n`);
return newVersion;
return tauriConf.version;
}

function main() {
const type = Bun.argv[2] as "major" | "minor" | "patch";
if (!["major", "minor", "patch"].includes(type)) {
console.error("Usage: bun run release.ts <major|minor|patch>");
process.exit(1);
}

async function main() {
try {
// Make sure we're on main branch and it's clean
execSync("git diff-index --quiet HEAD --");
execSync("git checkout main");
execSync("git pull origin main");
$`git diff-index --quiet HEAD --`;
$`git checkout main`;
$`git pull origin main`;

// Update version
const newVersion = updateVersion(type);

// Create changelog entry
updateChangelog(newVersion);
const newVersion = getVersion();
const tag = `v${newVersion}`;

// Commit and push changes
execSync(`git commit -am "Bump version to ${newVersion}"`);
// Delete existing release branch locally and remotely if it exists
try {
execSync("git branch -D release");
} catch (e) {
// Branch doesn't exist locally, that's fine
// Check that the tag doesn't already exist
const tags = await $`git tag --list`;
if (tags.text().includes(tag)) {
throw `Tag ${tag} already exists`;
}
try {
execSync("git push origin :release");
} catch (e) {
// Branch doesn't exist remotely, that's fine
}

// Create and push new release branch
execSync("git checkout -b release");
execSync("git push origin release --force");
execSync(`git tag -a v${newVersion} -m "Release v${newVersion}"`);
execSync("git push origin --tags");

// Go back to main
execSync("git checkout main");
$`git tag -a v${newVersion} -m "Release v${newVersion}"`;
$`git push origin --tags --all`;

console.log(`\nReleased version ${newVersion}!`);
console.log("1. Update CHANGELOG.md with the actual changes");
console.log("2. Wait for GitHub Actions to finish");
console.log("3. Go to GitHub releases to review and publish");
console.log("\nReleasing version $newVersion!");
console.log("1. Wait for GitHub Actions to finish");
console.log(
"2. Go to https://github.com/blopker/alic/releases to review and publish",
);
} catch (error) {
console.error("Error:", error);
process.exit(1);
Expand Down

0 comments on commit 4040a3b

Please sign in to comment.