Include changelogs in deb package (#563)

* Initial attempt at custom Debian changelogs

* Iterate

* Quotes...

* Iterate

* facepalm

* Iterate

* Remove reundant line

* Ifs

* Test

* Iterate

* Iterate

* Brackets

* inconsistent?

* Update build_and_test.yaml

* Update build_and_test.yaml
This commit is contained in:
Michael Telatynski 2023-03-07 15:53:53 +00:00 committed by GitHub
parent 25af58e86f
commit 22fe702b83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 90 additions and 159 deletions

View file

@ -49,7 +49,7 @@ jobs:
with:
config: element.io/${{ inputs.mode || 'nightly' }}
version: ${{ inputs.mode == 'release' && '' || 'develop' }}
calculate-nightly-versions: ${{ inputs.mode != 'release' }}
nightly: ${{ inputs.mode != 'release' }}
secrets:
CF_R2_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY_ID }}
CF_R2_TOKEN: ${{ secrets.CF_R2_TOKEN }}
@ -98,6 +98,7 @@ jobs:
name: Linux
uses: ./.github/workflows/build_linux.yaml
with:
config: element.io/${{ inputs.mode || 'nightly' }}
sqlcipher: system
version: ${{ needs.prepare.outputs.linux-version }}

View file

@ -31,6 +31,7 @@ jobs:
matrix:
sqlcipher: [system, static]
with:
config: ${{ github.event.pull_request.base.ref == 'develop' && 'element.io/nightly' || 'element.io/release' }}
sqlcipher: ${{ matrix.sqlcipher }}
macos:

View file

@ -4,6 +4,10 @@
on:
workflow_call:
inputs:
config:
type: string
required: true
description: "The config directory to use"
version:
type: string
required: false
@ -60,16 +64,26 @@ jobs:
run: |
echo "config-args=--nightly '${{ inputs.version }}'" >> $GITHUB_OUTPUT
- name: Generate debian control file
- name: Generate debian files and arguments
id: debian
run: |
cp element.io/${{ inputs.version && 'nightly' || 'release' }}/control.template debcontrol
INPUT_VERSION="${{ inputs.version }}"
if [ -f changelog.Debian ]; then
echo "config-args=--deb-changelog changelog.Debian" >> $GITHUB_OUTPUT
fi
cp "$DIR/control.template" debcontrol
VERSION=${INPUT_VERSION:-$(cat package.json | jq -r .version)}
echo "Version: $VERSION" >> debcontrol
env:
DIR: ${{ inputs.config }}
INPUT_VERSION: ${{ inputs.version }}
- name: Build App
run: |
scripts/generate-builder-config.ts ${{ steps.nightly.outputs.config-args }} --deb-custom-control=debcontrol
scripts/generate-builder-config.ts \
${{ steps.nightly.outputs.config-args }} \
${{ steps.debian.outputs.config-args }} \
--deb-custom-control=debcontrol
yarn build --publish never -l --config electron-builder.json
- name: Upload Artifacts

View file

@ -10,37 +10,38 @@ on:
type: string
required: false
description: "The version tag to fetch, or 'develop', will pick automatically if not passed"
calculate-nightly-versions:
type: string
nightly:
type: boolean
required: false
description: "Whether to calculate the version strings new Nightly builds should use"
default: false
description: "Whether the build is a Nightly and to calculate the version strings new builds should use"
secrets:
# Required if `calculate-nightly-versions` is set
# Required if `nightly` is set
CF_R2_ACCESS_KEY_ID:
required: false
# Required if `calculate-nightly-versions` is set
# Required if `nightly` is set
CF_R2_TOKEN:
required: false
# Required if `calculate-nightly-versions` is set
# Required if `nightly` is set
CF_R2_S3_API:
required: false
outputs:
macos-version:
description: "The version string the next macOS Nightly should use, only output for calculate-nightly-versions"
description: "The version string the next macOS Nightly should use, only output for nightly"
value: ${{ jobs.prepare.outputs.macos-version }}
linux-version:
description: "The version string the next Linux Nightly should use, only output for calculate-nightly-versions"
description: "The version string the next Linux Nightly should use, only output for nightly"
value: ${{ jobs.prepare.outputs.linux-version }}
win32-x64-version:
description: "The version string the next Windows x64 Nightly should use, only output for calculate-nightly-versions"
description: "The version string the next Windows x64 Nightly should use, only output for nightly"
value: ${{ jobs.prepare.outputs.win32-x64-version }}
win32-x86-version:
description: "The version string the next Windows x86 Nightly should use, only output for calculate-nightly-versions"
description: "The version string the next Windows x86 Nightly should use, only output for nightly"
value: ${{ jobs.prepare.outputs.win32-x86-version }}
jobs:
prepare:
name: Prepare
environment: ${{ inputs.calculate-nightly-versions && 'packages.element.io' || '' }}
environment: ${{ inputs.nightly && 'packages.element.io' || '' }}
runs-on: ubuntu-latest
outputs:
macos-version: ${{ steps.versions.outputs.macos }}
@ -66,19 +67,9 @@ jobs:
yarn run --silent electron --version > electronVersion
cat package.json | jq -c .hakDependencies > hakDependencies.json
- uses: actions/upload-artifact@v3
with:
name: webapp
retention-days: 1
path: |
webapp.asar
package.json
electronVersion
hakDependencies.json
- name: Calculate Nightly versions
- name: "[Nightly] Calculate versions"
id: versions
if: inputs.calculate-nightly-versions
if: inputs.nightly
run: |
MACOS=$(aws s3 cp s3://$R2_BUCKET/nightly/update/macos/releases.json - --endpoint-url $R2_URL --region auto | jq -r .currentRelease)
echo "macos=$(scripts/generate-nightly-version.ts --latest $MACOS)" >> $GITHUB_OUTPUT
@ -96,3 +87,41 @@ jobs:
# XXX: UPDATE THIS BEFORE WHEN GOING LIVE
R2_BUCKET: "packages-element-io-test"
R2_URL: ${{ secrets.CF_R2_S3_API }}
- name: Check version
id: package
run: |
echo "version=$(cat package.json | jq -r .version)" >> $GITHUB_OUTPUT
- name: "[Release] Fetch release"
id: release
if: ${{ !inputs.nightly && inputs.version != 'develop' }}
uses: cardinalby/git-get-release-action@cedef2faf69cb7c55b285bad07688d04430b7ada # v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag: v${{ steps.package.outputs.version }}
- name: "[Release] Write changelog"
if: ${{ !inputs.nightly && inputs.version != 'develop' }}
run: |
TIME=$(date -d "$PUBLISHED_AT" -R)
echo "element-desktop ($VERSION) default; urgency=medium" >> changelog.Debian
echo "$BODY" | sed 's/^##/\n */g;s/^\*/ */g' | perl -pe 's/\[.+?]\((.+?)\)/\1/g' >> changelog.Debian
echo "" >> changelog.Debian
echo " -- ${{ github.actor }} <support@element.io> $TIME" >> changelog.Debian
env:
VERSION: v${{ steps.package.outputs.version }}
BODY: ${{ steps.release.outputs.body }}
PUBLISHED_AT: ${{ steps.release.outputs.published_at }}
- uses: actions/upload-artifact@v3
with:
name: webapp
retention-days: 1
path: |
webapp.asar
package.json
electronVersion
hakDependencies.json
changelog.Debian

View file

@ -1,81 +0,0 @@
Origin: riot.im
Codename: default
Architectures: amd64 i386 source
Components: main
SignWith: D7B0B66941D01538
Tracking: minimal
Origin: riot.im
Suite: oldoldstable
Codename: jessie
Architectures: amd64 i386 source
Components: main
SignWith: D7B0B66941D01538
Tracking: minimal
Origin: riot.im
Suite: oldstable
Codename: stretch
Architectures: amd64 i386 source
Components: main
SignWith: D7B0B66941D01538
Tracking: minimal
Origin: riot.im
Suite: stable
Codename: buster
Architectures: amd64 i386 source
Components: main
SignWith: D7B0B66941D01538
Tracking: minimal
Origin: riot.im
Suite: testing
Codename: bullseye
Architectures: amd64 i386 source
Components: main
SignWith: D7B0B66941D01538
Tracking: minimal
Origin: riot.im
Suite: unstable
Codename: sid
Architectures: amd64 i386 source
Components: main
SignWith: D7B0B66941D01538
Tracking: minimal
Origin: riot.im
Codename: xenial
Architectures: amd64 i386 source
Components: main
SignWith: D7B0B66941D01538
Tracking: minimal
Origin: riot.im
Codename: bionic
Architectures: amd64 i386 source
Components: main
SignWith: D7B0B66941D01538
Tracking: minimal
Origin: riot.im
Codename: cosmic
Architectures: amd64 i386 source
Components: main
SignWith: D7B0B66941D01538
Tracking: minimal
Origin: riot.im
Codename: disco
Architectures: amd64 i386 source
Components: main
SignWith: D7B0B66941D01538
Tracking: minimal
Origin: riot.im
Codename: eoan
Architectures: amd64 i386 source
Components: main
SignWith: D7B0B66941D01538
Tracking: minimal

View file

@ -15,6 +15,7 @@
import parseArgs from "minimist";
import fsProm from "fs/promises";
import * as os from "os";
import { Configuration } from "app-builder-lib";
const ELECTRON_BUILDER_CFG_FILE = "electron-builder.json";
@ -26,53 +27,14 @@ const argv = parseArgs<{
"signtool-thumbprint"?: string;
"signtool-subject-name"?: string;
"deb-custom-control"?: string;
"deb-changelog"?: string;
}>(process.argv.slice(2), {
string: ["nightly", "deb-custom-control", "signtool-thumbprint", "signtool-subject-name"],
string: ["nightly", "deb-custom-control", "deb-changelog", "signtool-thumbprint", "signtool-subject-name"],
});
interface File {
from: string;
to: string;
}
type DeepWriteable<T> = { -readonly [P in keyof T]: DeepWriteable<T[P]> };
interface PackageBuild {
appId: string;
asarUnpack: string;
files: Array<string | File>;
extraResources: Array<string | File>;
linux: {
target: string;
category: string;
maintainer: string;
desktop: {
StartupWMClass: string;
};
};
mac: {
category: string;
darkModeSupport: boolean;
};
win: {
target: {
target: string;
};
sign?: string;
signingHashAlgorithms?: string[];
certificateSubjectName?: string;
certificateSha1?: string;
};
deb?: {
fpm?: string[];
};
directories: {
output: string;
};
afterPack: string;
afterSign: string;
protocols: Array<{
name: string;
schemes: string[];
}>;
interface PackageBuild extends DeepWriteable<Omit<Configuration, "extraMetadata">> {
extraMetadata?: {
productName?: string;
name?: string;
@ -114,10 +76,10 @@ async function main(): Promise<number | void> {
}
if (argv["signtool-thumbprint"] && argv["signtool-subject-name"]) {
delete cfg.win.sign;
cfg.win.signingHashAlgorithms = ["sha256"];
cfg.win.certificateSubjectName = argv["signtool-subject-name"];
cfg.win.certificateSha1 = argv["signtool-thumbprint"];
delete cfg.win!.sign;
cfg.win!.signingHashAlgorithms = ["sha256"];
cfg.win!.certificateSubjectName = argv["signtool-subject-name"];
cfg.win!.certificateSha1 = argv["signtool-thumbprint"];
}
if (os.platform() === "linux") {
@ -125,10 +87,15 @@ async function main(): Promise<number | void> {
// https://github.com/vector-im/element-web/issues/13171
cfg.extraMetadata!.productName = cfg.extraMetadata!.productName!.replace(/ /g, "-");
cfg.deb = {
fpm: [],
};
if (argv["deb-custom-control"]) {
cfg.deb = {
fpm: [`--deb-custom-control=${argv["deb-custom-control"]}`],
};
cfg.deb.fpm!.push(`--deb-custom-control=${argv["deb-custom-control"]}`);
}
if (argv["deb-changelog"]) {
cfg.deb.fpm!.push(`--deb-changelog=${argv["deb-changelog"]}`);
}
}