Skip to content

Commit

Permalink
merge(release/1.2.4): windows installer + vc_redist
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Apr 2, 2023
2 parents 03352fa + 1d3c3ac commit e5b31e9
Show file tree
Hide file tree
Showing 16 changed files with 516 additions and 143 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.github
dist
node_modules
venv
Expand Down
84 changes: 84 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: build
on:
push:
branches:
- master
- release/*

jobs:
build:
name: build
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v3

- name: Build docker stage export
run: docker buildx build --target=export --output=. .

- name: Find file name with pattern monitorrent-*.zip
id: find-file
run: echo "release-zip=$(ls monitorrent-*.zip)" >> $GITHUB_OUTPUT

- name: Upload release zip
uses: actions/upload-artifact@v3
with:
name: release
path: ${{ steps.find-file.outputs.release-zip }}

build-msi:
name: build msi
runs-on: windows-latest
needs: build
steps:

- name: Checkout
uses: actions/checkout@v3

- name: Download release zip
uses: actions/download-artifact@v3
with:
name: release
path: .artifacts

- name: Find release zip in downloaded artifacts on Windows
id: find-release-zip
run: |
"release-zip=$(ls .artifacts/monitorrent-*.zip)" >> $env:GITHUB_OUTPUT
- name: Unzip release zip to dist folder
run: 7z x ${{ steps.find-release-zip.outputs.release-zip }} -odist

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
architecture: 'x86'

- name: Install python requirements
run: pip install -r requirements.txt

- name: Setup msbuild
uses: microsoft/setup-msbuild@v1.3
with:
vs-version: 17.5

- name: Setup nuget
uses: nuget/setup-nuget@v1

- name: Restore solution
run: |
cd MonitorrentInstaller
nuget restore
- name: Build vs solution
run: |
cd MonitorrentInstaller
msbuild /p:Platform="x86" /p:Configuration=Release /p:PythonLocation=$env:pythonLocation /t:Rebuild
- name: Upload msi
uses: actions/upload-artifact@v3
with:
name: installer
path: MonitorrentInstaller\MonitorrentBundle\bin\Release\MonitorrentInstaller.exe
139 changes: 139 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: release
on:
workflow_dispatch:
inputs:
release_description:
description: 'Release description'
required: true
type: string

jobs:
createRelease:
name: Merge release branch into master
runs-on: ubuntu-latest
steps:

- name: extract version from branch name by removing release/ prefix
id: extract-version
run: |
echo "version=${GITHUB_REF#refs/heads/release/}" >> $GITHUB_OUTPUT
- name: Fail if version is empty
if: ${{ steps.extract-version.outputs.version == '' }}
run: exit 1

- name: Checkout master
uses: actions/checkout@v3
with:
ref: master
fetch-depth: 0

- name: merge current branch into master
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git merge --no-edit --no-ff -m "merge(release/${{ steps.extract-version.outputs.version }}): ${{ github.event.inputs.release_description }}" origin/release/${{ steps.extract-version.outputs.version }}
git push origin master
- name: Create tag
run: |
git tag ${{ steps.extract-version.outputs.version }}
git push origin ${{ steps.extract-version.outputs.version }}
- name: Download artifact from latest workflow run on branch
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require("fs");
const path = require("path");
const workflowName = 'build';
const branchName = process.env.GITHUB_REF.split('/').slice(2).join('/');
const artifactNames = ['release', 'installer'];
const workflows = await github.rest.actions.listRepoWorkflows({
owner: context.repo.owner,
repo: context.repo.repo,
});
// Log all workflows as json
// console.log(JSON.stringify(workflows.data, null, 2));
const workflow = workflows.data.workflows.find(w => w.name === workflowName);
const runs = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 1,
branch: branchName,
workflow_id: workflow.id,
status: 'success',
});
// Log all workflows as json
// console.log(JSON.stringify(runs.data, null, 2));
const runId = runs.data.workflow_runs[0].id;
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: runId,
});
// Log all workflows as json
// console.log(JSON.stringify(artifacts.data, null, 2));
const artifactIds = {};
for (const name of artifactNames) {
const artifact = artifacts.data.artifacts.find(a => a.name === name);
if (artifact) {
artifactIds[name] = artifact.id;
} else {
console.log(`Artifact ${name} not found in latest workflow run.`);
}
}

const targetDir = '.artifacts';
if (!fs.existsSync(targetDir)) {
fs.mkdirSync(targetDir, { recursive: true });
}

for (const [name, id] of Object.entries(artifactIds)) {
const response = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: id,
archive_format: 'zip',
});
const filePath = path.join(targetDir, `${name}.zip`);
fs.writeFileSync(filePath, Buffer.from(response.data));
}

- name: Unzip .artifacts
run: |
unzip .artifacts/release.zip -d .artifacts
unzip .artifacts/installer.zip -d .artifacts
mv .artifacts/MonitorrentInstaller.exe .artifacts/MonitorrentInstaller-${{ steps.extract-version.outputs.version }}.exe
rm .artifacts/release.zip
rm .artifacts/installer.zip
- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: .artifacts/*
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ steps.extract-version.outputs.version }} - ${{ github.event.inputs.release_description }}
tag: ${{ steps.extract-version.outputs.version }}
makeLatest: true
bodyFile: RELEASE_NOTES.md
draft: false
prerelease: false

- name: Merge into develop
run: |
git checkout develop
git merge --no-edit --no-ff -m "merge(master): merge back" origin/master
git push origin develop
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,7 @@ report.html
/venv/
/out/
/MonitorrentInstaller/browsers/

/browsers/
/MonitorrentInstaller/vcredist/
/MonitorrentInstaller/nssm/
/MonitorrentInstaller/nssm.zip
20 changes: 20 additions & 0 deletions MonitorrentInstaller/MonitorrentBundle/Bundle.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Bundle Name="Monitorrent Installer" Version="1.2.4.100" Manufacturer="Monitorrent Team" UpgradeCode="cb50686e-6598-4da5-95bc-b36151a7f4ed">

<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
<bal:WixStandardBootstrapperApplication
LicenseFile="$(var.MonitorrentInstaller.ProjectDir)license.rtf"
SuppressOptionsUI="yes"
/>
</BootstrapperApplicationRef>

<Chain>
<ExePackage Id="VCRedist" SourceFile="$(var.SolutionDir)/vcredist/vc_redist.x86.exe" InstallCommand="/q" />
<MsiPackage SourceFile="$(var.MonitorrentInstaller.TargetPath)" DisplayInternalUI="yes" >
<MsiProperty Name="LICENSE_ACCEPTED" Value="1" />
</MsiPackage>
</Chain>
</Bundle>
</Wix>
67 changes: 67 additions & 0 deletions MonitorrentInstaller/MonitorrentBundle/MonitorrentBundle.wixproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\WiX.3.11.2\build\wix.props" Condition="Exists('..\packages\WiX.3.11.2\build\wix.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>3.10</ProductVersion>
<ProjectGuid>{20359269-a60b-4113-b8d8-c9bae586379d}</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>MonitorrentInstaller</OutputName>
<OutputType>Bundle</OutputType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="Bundle.wxs" />
</ItemGroup>
<ItemGroup>
<WixExtension Include="WixBalExtension">
<HintPath>$(WixExtDir)\WixBalExtension.dll</HintPath>
<Name>WixBalExtension</Name>
</WixExtension>
</ItemGroup>
<ItemGroup>
<Content Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MonitorrentInstaller\MonitorrentInstaller.wixproj">
<Name>MonitorrentInstaller</Name>
<Project>{0f6b9fd9-b7ff-4f43-a7a5-08e00a7da154}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
</ItemGroup>
<Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
<Target Name="DownloadVCRedist" Condition="!Exists('$(SolutionDir)/vcredist/vc_redist.x86.exe')" AfterTargets="BeforeBuild">
<!-- Download VC Redist -->
<Message Text="Downloading VC Redist from https://aka.ms/vs/17/release/vc_redist.x86.exe to $(SolutionDir)/vcredist/vc_redist.x86.exe" />
<DownloadFile SourceUrl="https://aka.ms/vs/17/release/vc_redist.x86.exe" DestinationFolder="$(SolutionDir)/vcredist" />
<!-- Copy folder pythonLocation env variable to ..\env folder -->
</Target>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\WiX.3.11.2\build\wix.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\WiX.3.11.2\build\wix.props'))" />
</Target>
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Wix.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
4 changes: 4 additions & 0 deletions MonitorrentInstaller/MonitorrentBundle/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="WiX" version="3.11.2" />
</packages>
13 changes: 11 additions & 2 deletions MonitorrentInstaller/MonitorrentInstaller.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
# Visual Studio Version 17
VisualStudioVersion = 17.5.33516.290
MinimumVisualStudioVersion = 10.0.40219.1
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "MonitorrentInstaller", "MonitorrentInstaller\MonitorrentInstaller.wixproj", "{0F6B9FD9-B7FF-4F43-A7A5-08E00A7DA154}"
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "MonitorrentBundle", "MonitorrentBundle\MonitorrentBundle.wixproj", "{20359269-A60B-4113-B8D8-C9BAE586379D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Expand All @@ -15,8 +17,15 @@ Global
{0F6B9FD9-B7FF-4F43-A7A5-08E00A7DA154}.Debug|x86.Build.0 = Debug|x86
{0F6B9FD9-B7FF-4F43-A7A5-08E00A7DA154}.Release|x86.ActiveCfg = Release|x86
{0F6B9FD9-B7FF-4F43-A7A5-08E00A7DA154}.Release|x86.Build.0 = Release|x86
{20359269-A60B-4113-B8D8-C9BAE586379D}.Debug|x86.ActiveCfg = Debug|x86
{20359269-A60B-4113-B8D8-C9BAE586379D}.Debug|x86.Build.0 = Debug|x86
{20359269-A60B-4113-B8D8-C9BAE586379D}.Release|x86.ActiveCfg = Release|x86
{20359269-A60B-4113-B8D8-C9BAE586379D}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FF1C17A8-F93A-4735-BD87-3E8B2D8040CB}
EndGlobalSection
EndGlobal
Loading

0 comments on commit e5b31e9

Please sign in to comment.