Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build portable in CI and automatically create a release #228

Merged
merged 1 commit into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .CI/build-installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ if ($isTagged) {
# Make sure, any existing `modes` file is overwritten for the user,
# for example when updating from nightly to stable.
Write-Output "" > Chatterino2/modes;
$installerBaseName = "Chatterino.Installer";
$installerBaseName = "Chatterino7.Installer";
}
else {
Write-Output nightly > Chatterino2/modes;
$defines = "/DIS_NIGHTLY=1";
$installerBaseName = "Chatterino.Nightly.Installer";
$installerBaseName = "Chatterino7.Nightly.Installer";
}

if ($Env:GITHUB_OUTPUT) {
Expand Down
61 changes: 61 additions & 0 deletions .CI/bundle-portable.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
if (-not (Test-Path -PathType Container Chatterino2)) {
Write-Error "Couldn't find a folder called 'Chatterino2' in the current directory.";
exit 1
}
if (-not $Env:C2_PORTABLE_INSTALLER_VERSION -or -not $Env:C2_PORTABLE_INSTALLER_SHA256) {
Write-Error "C2_PORTABLE_INSTALLER_VERSION or C2_PORTABLE_INSTALLER_SHA256 not defined.";
exit 1
}

function Remove-IfExists {
param (
[string] $Path
)
if (Test-Path -PathType Container $Path) {
Remove-Item $Path -Force -Recurse -Confirm:$false;
}
elseif (Test-Path -PathType Leaf $Path) {
Remove-Item $Path -Force;
}
}

# Check if we're on a tag
$OldErrorActionPref = $ErrorActionPreference;
$ErrorActionPreference = 'Continue';
git describe --exact-match --match 'v*' *> $null;
$ErrorActionPreference = $OldErrorActionPref;

Write-Output portable > Chatterino2/modes;
if ($isTagged) {
# This is a release.
# Make sure, any existing `modes` file is overwritten for the user,
# for example when updating from nightly to stable.
$bundleBaseName = "Chatterino7.Portable";
}
else {
Write-Output nightly >> Chatterino2/modes;
$bundleBaseName = "Chatterino7.Nightly.Portable";
}

if ($Env:GITHUB_OUTPUT) {
# This is used in CI when creating the artifact
"C2_PORTABLE_BASE_NAME=$bundleBaseName" >> "$Env:GITHUB_OUTPUT"
}

Remove-IfExists "Chatterino2/updater.1";
New-Item "Chatterino2/updater.1" -ItemType Directory;

Invoke-RestMethod "https://github.com/Nerixyz/c2-portable-updater/releases/download/$($Env:C2_PORTABLE_INSTALLER_VERSION)/c2-portable-updater-x86_64-pc-windows-msvc.zip" -OutFile _portable-installer.zip;
$updaterHash = (Get-FileHash _portable-installer.zip).Hash.ToLower();
if (-not $updaterHash -eq $Env:C2_PORTABLE_INSTALLER_SHA256) {
Write-Error "Hash mismatch: expected $($Env:C2_PORTABLE_INSTALLER_SHA256) - got: $updaterHash";
exit 1
}

7z e -y _portable-installer.zip c2-portable-updater.exe;
Move-Item c2-portable-updater.exe "Chatterino2/updater.1/ChatterinoUpdater.exe" -Force;
7z e -so _portable-installer.zip LICENSE-MIT > "Chatterino2/updater.1/LICENSE";
Remove-IfExists _portable-installer.zip;

Remove-IfExists "$bundleBaseName$($Env:VARIANT_SUFFIX).zip";
7z a "$bundleBaseName$($Env:VARIANT_SUFFIX).zip" Chatterino2/;
8 changes: 4 additions & 4 deletions .CI/chatterino-installer.iss
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Chatterino"
#define MyAppVersion "2.4.4"
#define MyAppPublisher "Chatterino Team"
#define MyAppName "Chatterino7"
#define MyAppVersion "7.4.4"
#define MyAppPublisher "7TV"
#define MyAppURL "https://www.chatterino.com"
#define MyAppExeName "chatterino.exe"

Expand Down Expand Up @@ -37,7 +37,7 @@ OutputDir=out
#ifdef INSTALLER_BASE_NAME
OutputBaseFilename={#INSTALLER_BASE_NAME}
#else
OutputBaseFilename=Chatterino.Installer
OutputBaseFilename=Chatterino7.Installer
#endif
Compression=lzma
SolidCompression=yes
Expand Down
135 changes: 134 additions & 1 deletion .github/workflows/create-installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ on:
workflows: ["Build"]
types: [completed]
# make sure this only runs on the default branch
branches: [master]
branches: [chatterino7]
workflow_dispatch:

env:
C2_PORTABLE_INSTALLER_VERSION: "v0.1.3"
C2_PORTABLE_INSTALLER_SHA256: "1226165a328e9b1ce96ccc1b3a641fe9020708b5e2f88a486e226e2b4f259aa8"
RELEASE_NIGHTLY_INSTALLER: "OFF"

jobs:
create-installer:
runs-on: windows-latest
Expand Down Expand Up @@ -49,8 +54,136 @@ jobs:
run: ..\.CI\build-installer.ps1
shell: powershell

- name: Bundle portable
id: bundle-portable
working-directory: build
run: ..\.CI\bundle-portable.ps1
shell: powershell

- name: Upload installer
uses: actions/upload-artifact@v3
with:
path: build/${{ steps.build-installer.outputs.C2_INSTALLER_BASE_NAME }}${{ env.VARIANT_SUFFIX }}.exe
name: ${{ steps.build-installer.outputs.C2_INSTALLER_BASE_NAME }}${{ env.VARIANT_SUFFIX }}.exe

- name: Upload portable
uses: actions/upload-artifact@v3
with:
path: build/${{ steps.bundle-portable.outputs.C2_PORTABLE_BASE_NAME }}${{ env.VARIANT_SUFFIX }}.zip
name: ${{ steps.bundle-portable.outputs.C2_PORTABLE_BASE_NAME }}${{ env.VARIANT_SUFFIX }}.zip

- name: Create nightly release
if: ${{ contains(steps.build-installer.outputs.C2_INSTALLER_BASE_NAME, 'Nightly') && env.RELEASE_NIGHTLY_INSTALLER == 'ON' }}
uses: ncipollo/[email protected]
with:
replacesArtifacts: true
allowUpdates: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
artifactErrorsFailBuild: true
artifacts: |
build/${{ steps.build-installer.outputs.C2_INSTALLER_BASE_NAME }}${{ env.VARIANT_SUFFIX }}.exe
build/${{ steps.bundle-portable.outputs.C2_PORTABLE_BASE_NAME }}${{ env.VARIANT_SUFFIX }}.zip
prerelease: true
name: Nightly Release
tag: nightly-build

check-release:
runs-on: ubuntu-latest
needs: create-installer
outputs:
IS_TAGGED: ${{ steps.is-rel.outputs.IS_TAGGED }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # allows for tags access
- name: Check Release
id: is-rel
run: |
set +e;
git describe --exact-match --match 'v*' &> /dev/null;
echo "IS_TAGGED=$?" >> "$GITHUB_OUTPUT";
shell: bash

draft-release:
runs-on: ubuntu-latest
needs: [create-installer, check-release]
if: ${{ needs.check-release.outputs.IS_TAGGED == '0' }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # allows for tags access

- uses: actions/download-artifact@v3
with:
name: Chatterino7.Installer.exe
path: build/
- uses: actions/download-artifact@v3
with:
name: Chatterino7.Portable.zip
path: build/
- uses: actions/download-artifact@v3
with:
name: Chatterino7.Installer.EXPERIMENTAL-Qt6.exe
path: build/
- uses: actions/download-artifact@v3
with:
name: Chatterino7.Portable.EXPERIMENTAL-Qt6.zip
path: build/

- name: Download artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow: build.yml
name_is_regexp: true
name: '((^[Cc]hatterino)-[^wW].+$)|(^.+\.7z$)'
path: build/

- name: Fix Directories
working-directory: build
run: |
for file in */ ; do
mv "$file$(find "$file" -type f -printf '%f')" ".tmp.${file%/}";
rm -rf "$file";
mv ".tmp.${file%/}" "${file%/}";
done
shell: bash

- name: Fix paths
working-directory: build
run: |
ls -l
mv Chatterino-ubuntu-22.04-Qt-5.15.2.deb Chatterino-Ubuntu-22.04.deb
mv Chatterino-ubuntu-22.04-Qt-6.2.4.deb EXPERIMENTAL-Chatterino-Ubuntu-22.04-Qt6.deb

mv Chatterino-x86_64-5.15.2.AppImage Chatterino-x86_64.AppImage
mv Chatterino-x86_64-6.2.4.AppImage EXPERIMENTAL-Chatterino-x86_64-Qt6.AppImage

mv Chatterino7.Installer.EXPERIMENTAL-Qt6.exe EXPERIMENTAL-Chatterino7.Qt6.Installer.exe
mv Chatterino7.Portable.EXPERIMENTAL-Qt6.zip EXPERIMENTAL-Chatterino7.Qt6.Portable.zip
mv chatterino-windows-x86-64-Qt-6.5.0-symbols.pdb.7z EXPERIMENTAL-Chatterino-Windows-Qt6-debug-symbols.pdb.7z
mv chatterino-windows-x86-64-Qt-5.15.2-symbols.pdb.7z Chatterino-Windows-debug-symbols.pdb.7z

mv chatterino-macos-Qt-5.15.2.dmg Chatterino.dmg
mv chatterino-macos-Qt-6.5.0.dmg EXPERIMENTAL-Chatterino.Qt6.dmg

- name: Hash files
working-directory: build
run: |
sha256sum * > sha256-checksums.txt

- name: Get Tag
id: get-tag
run: echo "VALUE=$(git describe --exact-match --match 'v*')" >> "$GITHUB_OUTPUT"
- name: Create release
uses: ncipollo/[email protected]
with:
replacesArtifacts: true
allowUpdates: true
artifactErrorsFailBuild: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
draft: true
artifacts: "build/*"
name: ${{ steps.get-tag.outputs.VALUE }}
tag: ${{ steps.get-tag.outputs.VALUE }}
Loading