Skip to content

Commit

Permalink
feat: generate update manifests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewinci committed Sep 27, 2022
1 parent ad4ed6b commit f937c03
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 30 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,31 @@ jobs:
with:
name: ${{ matrix.os }}-artifacts
path: src-tauri/target/release/bundle/*
retention-days: 5
retention-days: 1

- name: Update darwin manifest
if: matrix.os == 'macos-latest'
run: |
./scripts/update-signatures.sh darwin
# remove unused manifest
rm -rf manifests/update-linux.json
- name: Update linux manifest
if: matrix.os == 'ubuntu-latest'
run: |
./scripts/update-signatures.sh linux
# remove unused manifest
rm -rf manifests/update-darwin.json
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
files: |
manifests/update-linux.json
src-tauri/target/release/bundle/deb/insulator-*_amd64.deb
src-tauri/target/release/bundle/appimage/insulator-*_amd64.AppImage
src-tauri/target/release/bundle/appimage/insulator-*_amd64.AppImage.tar.gz
src-tauri/target/release/bundle/appimage/insulator-*_amd64.AppImage.tar.gz.sig
manifests/update-darwin.json
src-tauri/target/release/bundle/dmg/*.dmg
src-tauri/target/release/bundle/macos/Insulator*.app.tar.gz
src-tauri/target/release/bundle/macos/Insulator*.app.tar.gz.sig
10 changes: 8 additions & 2 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@
[
"@semantic-release/exec",
{
"prepareCmd": "./scripts/publish.sh ${nextRelease.version}"
"prepareCmd": "./scripts/publish.sh ${nextRelease.version} \"${nextRelease.notes}\""
}
],
[
"@semantic-release/git",
{
"assets": ["src-tauri/tauri.conf.json", "CHANGELOG.md", "package.json"],
"assets": [
"src-tauri/tauri.conf.json",
"CHANGELOG.md",
"package.json",
"manifests/update-darwin.json",
"manifests/update-linux.json"
],
"message": "chore(release): ${nextRelease.version} \n\n${nextRelease.notes}"
}
],
Expand Down
15 changes: 15 additions & 0 deletions manifests/update-darwin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "v0.0.1",
"notes": "Release notes example 2",
"pub_date": "2022-09-27T05:00:54Z",
"platforms": {
"darwin-x86_64": {
"signature": "----",
"url": "template"
},
"darwin-aarch64": {
"signature": "-----",
"url": "template"
}
}
}
11 changes: 11 additions & 0 deletions manifests/update-linux.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "v0.0.1",
"notes": "Release notes example 2",
"pub_date": "2022-09-27T05:00:54Z",
"platforms": {
"linux-x86_64": {
"signature": "-----",
"url": "template"
}
}
}
21 changes: 18 additions & 3 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
#!/bin/bash

set -e

VERSION=$1
RELEASE_NOTES="${*:2}"
NOW=$(python -c "import datetime; print(datetime.datetime.now().strftime(\"%Y-%m-%dT%H:%M:%SZ\"))")

echo "Update version to $VERSION"

function update_json() {
FILE_NAME=$1
JSON_PATH=$2
VALUE=$3
jq "$JSON_PATH = \"$VALUE\"" <<< $(cat $FILE_NAME) > $FILE_NAME
jq "$JSON_PATH = \"$VALUE\"" <<<$(cat $FILE_NAME) >$FILE_NAME
}

# Update package.json
update_json package.json ".version" $VERSION

# Update tauri
update_json src-tauri/tauri.conf.json ".package.version" $VERSION
update_json src-tauri/tauri.conf.json ".package.version" $VERSION

# Update mac os manifest
update_json manifests/update-darwin.json '.version' "v$VERSION"
update_json manifests/update-darwin.json '.pub_date' "$NOW"
update_json manifests/update-darwin.json '.platforms."darwin-x86_64".url' "https://github.com/andrewinci/insulator2/releases/download/v${VERSION}/Insulator.2.app.tar.gz"
update_json manifests/update-darwin.json '.platforms."darwin-aarch64".url' "https://github.com/andrewinci/insulator2/releases/download/v${VERSION}/Insulator.2.app.tar.gz"
update_json manifests/update-darwin.json ".notes" "$RELEASE_NOTES"

# Update linux manifest
update_json manifests/update-linux.json '.version' "v$VERSION"
update_json manifests/update-linux.json '.pub_date' "$NOW"
update_json manifests/update-linux.json '.platforms."linux-x86_64".url' "https://github.com/andrewinci/insulator2/releases/download/v${VERSION}/insulator-2_${VERSION}_amd64.AppImage.tar.gz"
update_json manifests/update-linux.json ".notes" "$RELEASE_NOTES"
25 changes: 25 additions & 0 deletions scripts/update-signatures.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -e

function update_json() {
FILE_NAME=$1
JSON_PATH=$2
VALUE=$3
jq "$JSON_PATH = \"$VALUE\"" <<<$(cat $FILE_NAME) >$FILE_NAME
}

TARGET="$1"

if [ "$TARGET" == "darwin" ]; then
echo "Updating darwin signatures"
SIG=$(cat "src-tauri/target/release/bundle/macos/Insulator 2.app.tar.gz.sig")
update_json manifests/update-darwin.json '.platforms."darwin-x86_64".signature' "$SIG"
update_json manifests/update-darwin.json '.platforms."darwin-aarch64".signature' "$SIG"
elif [ "$TARGET" == "linux" ]; then
echo "Updating linux signatures"
SIG=$(cat src-tauri/target/release/bundle/appimage/insulator-*_amd64.AppImage.tar.gz.sig)
update_json manifests/update-linux.json '.platforms."linux-x86_64".signature' "$SIG"
else
echo "Invalid target. Specify one of: linux, darwin"
exit 1
fi
19 changes: 0 additions & 19 deletions scripts/update_template.json

This file was deleted.

11 changes: 8 additions & 3 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"package": {
"productName": "Insulator 2",
"version": "1.4.0"
"version": "0.0.1"
},
"tauri": {
"allowlist": {
Expand All @@ -21,7 +21,12 @@
"depends": []
},
"externalBin": [],
"icon": ["icons/32x32.png", "icons/128x128.png", "icons/icon.icns", "icons/icon.ico"],
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/icon.icns",
"icons/icon.ico"
],
"identifier": "com.insulator",
"longDescription": "",
"macOS": {
Expand All @@ -46,7 +51,7 @@
"updater": {
"active": true,
"endpoints": [
"https://github.com/andrewinci/insulator2/releases/latest/download/update.json"
"https://github.com/andrewinci/insulator2/releases/latest/download/update-{{target}}.json"
],
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDcyOURCOTAxOUExRDcwQTUKUldTbGNCMmFBYm1kY2lvd3Rvc0Z2ZitiVTZSWkZGMWJHZ2FoUkxVOVJHL3hTVFlaeUJKNU92bTEK"
},
Expand Down

0 comments on commit f937c03

Please sign in to comment.