Skip to content

Commit

Permalink
CI: Prepare release 'v1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
BetterDiscord CI authored and BetterDiscord CI committed Oct 22, 2022
2 parents 3a18de5 + 34dc2b9 commit 57d0bfa
Show file tree
Hide file tree
Showing 13 changed files with 1,153 additions and 608 deletions.
19 changes: 19 additions & 0 deletions .github/RELEASE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!--
The release pipeline uses this file to draft a github release. (unless that's where you are reading this)
The following literals will be replaced with meaningful values:
$SHA1 The full hash of this build's commit.
$OLD_VERSION The previous release's (guessed) version number. Reconstructed by reading `package.json`.
$NEW_VERSION This release's version number. (sanitized)
$NAKED_INPUT_VERSION_TAG Whatever will have been written into the pipeline trigger.
-->

## What's Changed
* New release pipeline by @Inve1951
* .......

<!--
## New Contributors
* @Baits4000 made their first contribution in #7000.
-->

The full list of changes can be viewed at https://github.com/BetterDiscord/Installer/compare/$OLD_VERSION...$NEW_VERSION
192 changes: 192 additions & 0 deletions .github/workflows/release-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
name: Release Pipeline

# Execution needs to be triggered manually at https://github.com/BetterDiscord/Installer/actions/workflows/release-pipeline.yml.

# This pipeline is pretty hard-coded and will deliver
# identical results no matter the branch it's run against.

on:
workflow_dispatch:
inputs:
version_tag:
description: The version label to be used for this release
required: true

concurrency: release

jobs:

# Checkout 'release', merge 'development', bump version, upload source artifact.
prepare:
name: Prepare Repo
runs-on: ubuntu-latest
outputs:
old_version: ${{ steps.version_bump.outputs.old_version }}
new_version: ${{ steps.version_bump.outputs.new_version }}
steps:

- name: checkout 'release'
uses: actions/checkout@v2
with:
ref: 'release'
fetch-depth: 0

- name: merge 'development' and bump version
id: version_bump
run: |
git config --global user.name "BetterDiscord CI"
git config --global user.email "BetterDiscord@users.noreply.github.com"
git merge --no-ff --no-commit 'origin/development'
node << 'EOF'
const fs = require("fs");
const packageJson = JSON.parse(fs.readFileSync("package.json", "utf-8"));
let version = process.env.VERSION_TAG;
if (/^v\d/.test(version)) version = version.slice(1);
if (
!/^\d/.test(version) || version.includes("-") && !/[a-z\d]$/.test(version)
) throw new Error(`Bad version tag: '${process.env.VERSION_TAG}'`);
if (version.includes("-") && !/\.\d+$/.test(version)) version += ".0";
version = version.replace(/\.+/g, ".");
fs.writeFileSync("package.json", JSON.stringify({
...packageJson,
version,
}, null, 2) + "\n");
let oldVersion = "v" + packageJson.version;
let newVersion = "v" + version;
console.log(`::set-output name=old_version::${oldVersion}`);
console.log(`::set-output name=new_version::${newVersion}`);
fs.writeFileSync("commit-message", `CI: Prepare release '${newVersion}`);
EOF
git add package.json
git commit -F commit-message
env:
VERSION_TAG: ${{ github.event.inputs.version_tag }}

- uses: actions/upload-artifact@v2
with:
name: source
path: |
./*
!.git/config
# Download source artifact, build, upload build artifact.
# Runs once on each release platform.
build:
name: Build
needs: prepare
strategy:
fail-fast: true
matrix:
os:
# ordered by how fast they build (muh cosmetics)
- ubuntu-latest
- windows-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:

- uses: actions/download-artifact@v2
with:
name: source

- run: yarn install && yarn dist

- uses: actions/upload-artifact@v2
if: ${{ success() && matrix.os == 'ubuntu-latest' }}
with:
name: build
path: dist/BetterDiscord-Linux.AppImage
if-no-files-found: error

- uses: actions/upload-artifact@v2
if: ${{ success() && matrix.os == 'windows-latest' }}
with:
name: build
path: dist/BetterDiscord-Windows.exe
if-no-files-found: error

- if: ${{ success() && matrix.os == 'macos-latest' }}
run: mv -f dist/BetterDiscord-*-mac.zip dist/BetterDiscord-Mac.zip
- if: ${{ success() && matrix.os == 'macos-latest' }}
uses: actions/upload-artifact@v2
with:
name: build
path: dist/BetterDiscord-Mac.zip
if-no-files-found: error

# Download source artifact, push to 'release'.
push_changes:
name: Push Version Bump
needs:
- prepare
- build
runs-on: ubuntu-latest
outputs:
sha_1: ${{ steps.push.outputs.sha_1 }}
steps:

- name: checkout 'development'
uses: actions/checkout@v2
with:
ref: 'development'
token: ${{ secrets.CI_PAT }}
clean: false
- uses: actions/download-artifact@v2
with:
name: source

- name: merge 'release' and push everything
id: push
run: |
git checkout 'development'
git config --global user.name "BetterDiscord CI"
git config --global user.email "BetterDiscord@users.noreply.github.com"
# TODO: rebase 'development' on 'release'
git merge --ff-only --no-commit 'release'
SHA1=$(git rev-parse --verify HEAD)
git tag "$NEW_VERSION" "$SHA1"
git push --all && git push --tags
echo "::set-output name=sha_1::$SHA1"
env:
NEW_VERSION: ${{ needs.prepare.outputs.new_version }}

# Download build artifact, do github release.
publish:
name: Draft Release
needs:
- prepare
- build
- push_changes
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2
with:
ref: ${{ needs.push_changes.outputs.sha_1 }}

- name: authenticate gh-cli
run: echo "$GITHUB_TOKEN_STUPIDO" | gh auth login --with-token
env:
GITHUB_TOKEN_STUPIDO: ${{ secrets.CI_PAT }}

- uses: actions/download-artifact@v2
with:
name: build

- name: upload release draft
run: |
cat "$RELEASE_NOTES_TEMPLATE_LOCATION" \
| sed -e 's/$SHA1/'"$SHA1"'/' - \
| sed -e 's/$OLD_VERSION/'"$OLD_VERSION"'/' - \
| sed -e 's/$NEW_VERSION/'"$NEW_VERSION"'/' - \
| sed -e 's/$NAKED_INPUT_VERSION_TAG/'"$NAKED_INPUT_VERSION_TAG"'/' - \
| gh release create "$NEW_VERSION" --draft --title "$NEW_VERSION" --target "$SHA1" --notes-file - \
"BetterDiscord-Linux.AppImage#Linux (AppImage)" \
"BetterDiscord-Mac.zip#Mac OS (Zip)" \
"BetterDiscord-Windows.exe#Windows (Exe)"
env:
SHA1: ${{ needs.push_changes.outputs.sha_1 }}
OLD_VERSION: ${{ needs.prepare.outputs.old_version }}
NEW_VERSION: ${{ needs.prepare.outputs.new_version }}
NAKED_INPUT_VERSION_TAG: ${{ github.event.inputs.version_tag }}
RELEASE_NOTES_TEMPLATE_LOCATION: .github/RELEASE_TEMPLATE.md
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"productName": "BetterDiscord Installer",
"description": "A simple standalone program which automates the installation, removal and maintenance of BetterDiscord.",
"author": "BetterDiscord",
"version": "1.1.1",
"version": "1.1.2",
"license": "MIT",
"scripts": {
"dev": "electron-webpack dev",
"compile": "electron-webpack",
"lint": "eslint --ext .svelte,.js src/",
"stats": "webpack --json --profile --config webpack.renderer.js > dist/stats.json",
"analyze": "webpack-bundle-analyzer dist/stats.json",
"dist": "yarn compile && electron-builder",
"dist": "yarn compile && electron-builder -p never",
"dist:dir": "yarn dist --dir -c.compression=store -c.mac.identity=null"
},
"dependencies": {
Expand All @@ -23,7 +23,7 @@
"electron-webpack": "^2.8.2",
"eslint": "^7.21.0",
"eslint-plugin-svelte3": "^3.1.2",
"find-process": "^1.4.4",
"find-process": "^1.4.7",
"focus-visible": "^5.2.0",
"phin": "^3.6.0",
"rimraf": "^3.0.2",
Expand Down
4 changes: 3 additions & 1 deletion src/main/update_installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const getJSON = phin.defaults({
followRedirects: true
});

/* eslint-disable no-console */
export default async function () {
const downloadUrl = "https://api.github.com/repos/BetterDiscord/Installer/releases";
console.info(`Better Discord Installer ${version}`);
Expand All @@ -35,7 +36,8 @@ export default async function () {
process.exit(0);
}

} else {
}
else {
console.info(`The installer is up to date.`);
}
}
Expand Down
17 changes: 13 additions & 4 deletions src/renderer/actions/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@ import {remote} from "electron";
export const platforms = {stable: "Discord", ptb: "Discord PTB", canary: "Discord Canary"};
export const locations = {stable: "", ptb: "", canary: ""};

const safeIsDir = (fullpath) => {
try {
return fs.lstatSync(fullpath).isDirectory();
}
catch {
return false;
}
};

const getDiscordPath = function(releaseChannel) {
let resourcePath = "";
if (process.platform === "win32") {
let basedir = path.join(process.env.LOCALAPPDATA, releaseChannel.replace(/ /g, "")); // Normal install path in AppData\Local
if (!fs.existsSync(basedir)) basedir = path.join(process.env.PROGRAMDATA, process.env.USERNAME, releaseChannel.replace(/ /g, "")); // Atypical location in ProgramData\%username%
if (!fs.existsSync(basedir)) return "";
const version = fs.readdirSync(basedir).filter(f => fs.lstatSync(path.join(basedir, f)).isDirectory() && f.split(".").length > 1).sort().reverse()[0];
const version = fs.readdirSync(basedir).filter(f => safeIsDir(path.join(basedir, f)) && f.split(".").length > 1).sort().reverse()[0];
if (!version) return "";
resourcePath = path.join(basedir, version, "resources");
}
Expand All @@ -21,7 +30,7 @@ const getDiscordPath = function(releaseChannel) {
else {
const basedir = path.join(remote.app.getPath("userData"), "..", releaseChannel.toLowerCase().replace(" ", ""));
if (!fs.existsSync(basedir)) return "";
const version = fs.readdirSync(basedir).filter(f => fs.lstatSync(path.join(basedir, f)).isDirectory() && f.split(".").length > 1).sort().reverse()[0];
const version = fs.readdirSync(basedir).filter(f => safeIsDir(path.join(basedir, f)) && f.split(".").length > 1).sort().reverse()[0];
if (!version) return "";
resourcePath = path.join(basedir, version, "modules", "discord_desktop_core");
}
Expand Down Expand Up @@ -56,7 +65,7 @@ const validateWindows = function(channel, proposedPath) {
const selected = path.basename(proposedPath);
const isBaseDir = selected === channelName;
if (isBaseDir) {
const version = fs.readdirSync(proposedPath).filter(f => fs.lstatSync(path.join(proposedPath, f)).isDirectory() && f.split(".").length > 1).sort().reverse()[0];
const version = fs.readdirSync(proposedPath).filter(f => safeIsDir(path.join(proposedPath, f)) && f.split(".").length > 1).sort().reverse()[0];
if (!version) return "";
resourcePath = path.join(proposedPath, version, "resources");
}
Expand Down Expand Up @@ -91,7 +100,7 @@ const validateLinux = function(channel, proposedPath) {
let resourcePath = "";
const selected = path.basename(proposedPath);
if (selected === channelName) {
const version = fs.readdirSync(proposedPath).filter(f => fs.lstatSync(path.join(proposedPath, f)).isDirectory() && f.split(".").length > 1).sort().reverse()[0];
const version = fs.readdirSync(proposedPath).filter(f => safeIsDir(path.join(proposedPath, f)) && f.split(".").length > 1).sort().reverse()[0];
if (!version) return "";
resourcePath = path.join(proposedPath, version, "modules", "discord_desktop_core");
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/common/Checkbox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import {handleKeyboardToggle, checkItem} from "../stores/controls.js";
export let checked = false;
export let label = undefined;
export let label = undefined; // eslint-disable-line no-undef-init
let checkbox;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/common/ProgressBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export let value = 0;
export let max = 100;
let className;
export { className as class };
export {className as class};
</script>

<div class="progress-bar {className}" {...$$restProps}>
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/common/SocialLinks.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import { tooltip } from "./tooltip";
import {tooltip} from "./tooltip";
const webUrl = "https://betterdiscord.app";
const githubUrl = "http://github.com/BetterDiscord/BetterDiscord";
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/common/Spinner.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
import { afterUpdate, onMount } from "svelte";
export let value = undefined;
let className = undefined;
import {afterUpdate, onMount} from "svelte";
export let value = undefined; // eslint-disable-line no-undef-init
let className = undefined; // eslint-disable-line no-undef-init
export {className as class};
let circle;
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/common/Text.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script>
export let hasMargin = undefined;;
export let hasMargin = undefined; // eslint-disable-line no-undef-init
export let type = "paragraph";
let className = undefined;
export { className as class };
let className = undefined; // eslint-disable-line no-undef-init
export {className as class};
</script>

{#if type === "header"}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/common/Tooltip.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
export let position = "top";
export let x = 0;
export let y = 0;
export let element = undefined;
export let element = undefined; // eslint-disable-line no-undef-init
$: colors = ["default", "danger", "accent"];
$: positions = ["top", "bottom", "left", "right"];
Expand Down
Loading

0 comments on commit 57d0bfa

Please sign in to comment.