Skip to content

Commit

Permalink
Merge pull request #38 from Tormak9970/dev
Browse files Browse the repository at this point in the history
chore: build v1.0.0
  • Loading branch information
Tormak9970 authored Oct 19, 2024
2 parents dff8931 + 9263f45 commit 98ebecd
Show file tree
Hide file tree
Showing 419 changed files with 40,593 additions and 3,154 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ If applicable, add screenshots to help explain your problem.


**System information (please complete the following information):**
- Browser: [e.g. Chrome, Firefox, Safari, etc]
- OS version: [e.g. iOS 17, Android 14, Windows 10, Arch KDE]
- Version [e.g. v1.0.0]

**Additional information**
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Feature request
about: Suggest an idea for Tunistic
about: Suggest an idea for Svunes
title: ''
labels: enhancement
assignees: Tormak9970
Expand Down
147 changes: 147 additions & 0 deletions .github/workflows/candidate-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: Release Candidate

on:
push:
branches:
- "release-candidate"

jobs:
create-release:
permissions:
contents: write
runs-on: ubuntu-22.04
outputs:
release_id: ${{ steps.create-release.outputs.result }}
change_log: ${{ steps.changelog.outputs.changelog }}
version: ${{ steps.changelog.outputs.version }}
tag: ${{ steps.changelog.outputs.tag }}

steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: release-candidate

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Generate Changelog for Release
id: changelog
uses: Tormak9970/reliable-changelog@v2
with:
github-token: ${{ secrets.github_token }}
tag-prefix: "rc-"
git-branch: "release-candidate"
current-version: "./package.json"
version-path: "version"
patch-version-bump-interval: "10"

- name: Create Release
id: create-release
uses: actions/github-script@v6
env:
RELEASE_TAG: ${{ steps.changelog.outputs.tag }}
RELEASE_LOG: ${{ steps.changelog.outputs.changelog }}
with:
script: |
const { data } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: process.env.RELEASE_TAG,
name: `Svunes ${process.env.RELEASE_TAG}`,
body: `${process.env.RELEASE_LOG}`,
draft: true,
prerelease: true
});
return data.id
build-tauri:
needs: create-release
permissions:
contents: write
strategy:
fail-fast: false
matrix:
platform: [ubuntu-22.04, windows-latest]

runs-on: ${{ matrix.platform }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: release-candidate

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: Install Rust Stable
uses: dtolnay/rust-toolchain@stable

- name: Install Dependencies (Linux Only)
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libasound2-dev
- name: Install Frontend Dependencies
run: bun install

- name: Build App
uses: tauri-apps/tauri-action@dev
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
with:
releaseId: ${{ needs.create-release.outputs.release_id }}
tagName: ${{ needs.create-release.outputs.tag }}
releaseBody: "Check Github for the release notes!"
releaseDraft: true
includeUpdaterJson: false
tauriScript: "bun tauri"

publish-release:
needs: [create-release, build-tauri]
permissions:
contents: write
runs-on: ubuntu-22.04

steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: release-candidate

- name: Update Release Assets
uses: ./.github/workflows/create-release-assets
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release_id: ${{ needs.create-release.outputs.release_id }}
release_tag: ${{ needs.create-release.outputs.tag }}
git_branch: "release-candidate"
change_log: ${{ needs.create-release.outputs.change_log }}

- name: Publish Release
id: publish-release
uses: actions/github-script@v6
env:
release_id: ${{ needs.create-release.outputs.release_id }}
with:
script: |
github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.release_id,
draft: false,
prerelease: true
})
169 changes: 169 additions & 0 deletions .github/workflows/create-release-assets/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
name: 'create-release-assets'
description: 'Creates release assets.'
author: 'Tormak'
inputs:
GITHUB_TOKEN:
description: "Your GitHub token."
required: true

git_branch:
description: "The target release branch."
required: true

release_id:
description: "The target release id."
required: true

release_tag:
description: "The target release tag."
required: true

change_log:
description: "The target release change log."
required: false

runs:
using: 'composite'
steps:
- name: Update Release Assets
uses: actions/github-script@v6
env:
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
release_id: ${{ inputs.release_id }}
release_tag: ${{ inputs.release_tag }}
git_branch: ${{ inputs.git_branch }}
change_log: ${{ inputs.change_log }}
with:
script: |
const fs = require("fs");
const path = require("path");
async function getReleaseAssetContents(id) {
const contents = (
await github.request(
'GET /repos/{owner}/{repo}/releases/assets/{asset_id}',
{
owner: context.repo.owner,
repo: context.repo.repo,
asset_id: id,
headers: {
accept: 'application/octet-stream',
},
}
)
).data;
return contents;
}
async function deleteReleaseAsset(id) {
await github.rest.repos.deleteReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
asset_id: id
});
}
async function uploadReleaseAsset(name, contents) {
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.release_id,
name: name,
data: contents
});
}
async function setReleaseAssetName(id, newName) {
await github.rest.repos.updateReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
asset_id: id,
name: newName
});
}
const appimageInstallerPath = path.resolve(process.cwd(), "build-resources", "appimage-installer.sh");
const appimageInstallerContents = fs.readFileSync(appimageInstallerPath, "utf-8");
core.info(`Release Tag: ${process.env.release_tag}`);
const modifiedContents = appimageInstallerContents.replace("VALUE_TO_SEARCH_FOR", process.env.release_tag);
await uploadReleaseAsset("appimage-installer.sh", Buffer.from(modifiedContents));
core.info("Uploaded appimage installer to release.");
if (process.env.git_branch == "release") {
const versionNoV = process.env.release_tag.substring(1);
const GENERIC_NAMES = {
"windowsInstaller": "svunes.msi",
"windowsUpdater": `svunes_${versionNoV}.msi.zip`,
"windowsUpdaterSig": `svunes_${versionNoV}.msi.zip.sig`,
"linuxInstaller": "svunes.AppImage",
"linuxUpdater": `svunes_${versionNoV}.AppImage.tar.gz`,
"linuxUpdaterSig": `svunes_${versionNoV}.AppImage.tar.gz.sig`
}
const assets = await github.rest.repos.listReleaseAssets({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.release_id
});
const winInstaller = assets.data.find((asset) => asset.name.endsWith(".msi"));
await setReleaseAssetName(winInstaller.id, GENERIC_NAMES["windowsInstaller"]);
const winUpdater = assets.data.find((asset) => asset.name.endsWith(".msi.zip"));
await setReleaseAssetName(winUpdater.id, GENERIC_NAMES["windowsUpdater"]);
const winUpdaterSig = assets.data.find((asset) => asset.name.endsWith(".msi.zip.sig"));
await setReleaseAssetName(winUpdaterSig.id, GENERIC_NAMES["windowsUpdaterSig"]);
const linuxInstaller = assets.data.find((asset) => asset.name.endsWith(".AppImage"));
await setReleaseAssetName(linuxInstaller.id, GENERIC_NAMES["linuxInstaller"]);
const linuxUpdater = assets.data.find((asset) => asset.name.endsWith(".AppImage.tar.gz"));
await setReleaseAssetName(linuxUpdater.id, GENERIC_NAMES["linuxUpdater"]);
const linuxUpdaterSig = assets.data.find((asset) => asset.name.endsWith(".AppImage.tar.gz.sig"));
await setReleaseAssetName(linuxUpdaterSig.id, GENERIC_NAMES["linuxUpdaterSig"]);
const latest = assets.data.find((asset) => asset.name === "latest.json");
const latestContentsBuff = Buffer.from(await getReleaseAssetContents(latest.id));
let latestContents = latestContentsBuff.toString();
latestContents = latestContents.replace(winUpdater.name, GENERIC_NAMES["windowsUpdater"]);
latestContents = latestContents.replace(linuxUpdater.name, GENERIC_NAMES["linuxUpdater"]);
const latestContentsJson = JSON.parse(latestContents);
latestContentsJson.notes = process.env.change_log;
latestContents = JSON.stringify(latestContentsJson, null, '\t');
await deleteReleaseAsset(latest.id);
await uploadReleaseAsset("latest.json", Buffer.from(latestContents));
const latestPath = path.resolve(process.cwd(), "latest.json");
fs.writeFileSync(latestPath, Buffer.from(latestContents));
const config = (prop, value) => exec.exec(`git config ${prop} "${value}"`);
const add = (file) => exec.exec(`git add ${file}`);
const commit = (message) => exec.exec(`git commit -m "${message}"`);
const push = (branch) => exec.exec(`git push origin ${branch} --follow-tags`);
const updateOrigin = (repo) => exec.exec(`git remote set-url origin ${repo}`);
core.setSecret(process.env.GITHUB_TOKEN);
updateOrigin(`https://x-access-token:${process.env.GITHUB_TOKEN}@github.com/${process.env.GITHUB_REPOSITORY}.git`);
config('user.email', "[email protected]");
config('user.name', "Svunes Release Action");
await add(".");
await commit("chore(release): updating latest.json to generated version.");
await push(process.env.git_branch);
core.info("Committed changes to latest.json.");
} else {
core.info("Skipping latest.json upload for non release build.");
}
Loading

0 comments on commit 98ebecd

Please sign in to comment.