Skip to content

Commit

Permalink
Add workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Nifury committed Jun 2, 2022
1 parent d62f7d4 commit c57948f
Show file tree
Hide file tree
Showing 6 changed files with 498 additions and 75 deletions.
19 changes: 19 additions & 0 deletions .github/actions/stage/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Stage'
description: 'Stage build'
inputs:
finished:
description: If a previous stage already finished the build, the stage will set all output variables to the input ones and exit
required: true
from_artifact:
description: If a previous stage already uploaded build artifacts, the stage will resume building
required: true
x86:
description: Build x86 binary
required: false
default: false
outputs:
finished:
description: If a previous stage already finished the build, the stage will set all output variables to the input ones and exit
runs:
using: 'node16'
main: 'index.js'
61 changes: 61 additions & 0 deletions .github/actions/stage/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const core = require('@actions/core');
const io = require('@actions/io');
const exec = require('@actions/exec');
const artifact = require('@actions/artifact');
const glob = require('@actions/glob');

async function run() {
process.on('SIGINT', function() {
})
const finished = core.getBooleanInput('finished', {required: true});
const from_artifact = core.getBooleanInput('from_artifact', {required: true});
const x86 = core.getBooleanInput('x86', {required: false})
console.log(`finished: ${finished}, artifact: ${from_artifact}`);
if (finished) {
core.setOutput('finished', true);
return;
}

const artifactClient = artifact.create();
const artifactName = x86 ? 'build-artifact-x86' : 'build-artifact';

if (from_artifact) {
await artifactClient.downloadArtifact(artifactName, 'C:\\ungoogled-chromium-windows\\build');
await exec.exec('7z', ['x', 'C:\\ungoogled-chromium-windows\\build\\artifacts.zip',
'-oC:\\ungoogled-chromium-windows\\build', '-y']);
await io.rmRF('C:\\ungoogled-chromium-windows\\build\\artifacts.zip');
}

const args = ['build.py', '--ci']
if (x86)
args.push('--x86')
const retCode = await exec.exec('python', args, {
cwd: 'C:\\ungoogled-chromium-windows',
ignoreReturnCode: true
});
if (retCode === 0) {
core.setOutput('finished', true);
const globber = await glob.create('C:\\ungoogled-chromium-windows\\build\\ungoogled-chromium*',
{matchDirectories: false});
let packageList = await globber.glob();
packageList = await Promise.all(packageList.map(async x => {
const part1 = x.substr(0, x.length - 4);
const part2 = x86 ? '_x86' : '_x64';
const part3 = x.substr(x.length - 4, 4);
const newPath = part1 + part2 + part3;
await io.mv(x, newPath);
return newPath;
}));
await artifactClient.uploadArtifact(x86 ? 'chromium-x86' : 'chromium', packageList,
'C:\\ungoogled-chromium-windows\\build', {retentionDays: 1});
} else {
await new Promise(r => setTimeout(r, 5000));
await exec.exec('7z', ['a', '-tzip', 'C:\\ungoogled-chromium-windows\\artifacts.zip',
'C:\\ungoogled-chromium-windows\\build\\src', '-mx=3', '-mtc=on'], {ignoreReturnCode: true});
await artifactClient.uploadArtifact(artifactName, ['C:\\ungoogled-chromium-windows\\artifacts.zip'],
'C:\\ungoogled-chromium-windows', {retentionDays: 1});
core.setOutput('finished', false);
}
}

run().catch(err => core.setFailed(err.message));
9 changes: 9 additions & 0 deletions .github/actions/stage/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"dependencies": {
"@actions/artifact": "^1.1.0",
"@actions/core": "^1.8.2",
"@actions/exec": "^1.1.1",
"@actions/glob": "^0.3.0",
"@actions/io": "^1.1.2"
}
}
283 changes: 283 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,283 @@
name: CI
on:
push:
tags:
- '*'
jobs:
build-1:
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Init
run: Copy-Item -Path . -Destination "C:\ungoogled-chromium-windows" -Recurse
- name: Setup Stage
run: npm install
working-directory: ./.github/actions/stage
- name: Run Stage
id: stage
uses: ./.github/actions/stage
with:
finished: false
from_artifact: false
outputs:
finished: ${{ steps.stage.outputs.finished }}
build-2:
needs: build-1
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Init
run: Copy-Item -Path . -Destination "C:\ungoogled-chromium-windows" -Recurse
- name: Setup Stage
run: npm install
working-directory: ./.github/actions/stage
- name: Run Stage
id: stage
uses: ./.github/actions/stage
with:
finished: ${{ join(needs.*.outputs.finished) }}
from_artifact: true
outputs:
finished: ${{ steps.stage.outputs.finished }}
build-3:
needs: build-2
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Init
run: Copy-Item -Path . -Destination "C:\ungoogled-chromium-windows" -Recurse
- name: Setup Stage
run: npm install
working-directory: ./.github/actions/stage
- name: Run Stage
id: stage
uses: ./.github/actions/stage
with:
finished: ${{ join(needs.*.outputs.finished) }}
from_artifact: true
outputs:
finished: ${{ steps.stage.outputs.finished }}
build-4:
needs: build-3
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Init
run: Copy-Item -Path . -Destination "C:\ungoogled-chromium-windows" -Recurse
- name: Setup Stage
run: npm install
working-directory: ./.github/actions/stage
- name: Run Stage
id: stage
uses: ./.github/actions/stage
with:
finished: ${{ join(needs.*.outputs.finished) }}
from_artifact: true
outputs:
finished: ${{ steps.stage.outputs.finished }}
build-5:
needs: build-4
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Init
run: Copy-Item -Path . -Destination "C:\ungoogled-chromium-windows" -Recurse
- name: Setup Stage
run: npm install
working-directory: ./.github/actions/stage
- name: Run Stage
id: stage
uses: ./.github/actions/stage
with:
finished: ${{ join(needs.*.outputs.finished) }}
from_artifact: true
outputs:
finished: ${{ steps.stage.outputs.finished }}
build-6:
needs: build-5
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Init
run: Copy-Item -Path . -Destination "C:\ungoogled-chromium-windows" -Recurse
- name: Setup Stage
run: npm install
working-directory: ./.github/actions/stage
- name: Run Stage
id: stage
uses: ./.github/actions/stage
with:
finished: ${{ join(needs.*.outputs.finished) }}
from_artifact: true
outputs:
finished: ${{ steps.stage.outputs.finished }}

build-x86-1:
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Init
run: Copy-Item -Path . -Destination "C:\ungoogled-chromium-windows" -Recurse
- name: Setup Stage
run: npm install
working-directory: ./.github/actions/stage
- name: Run Stage
id: stage
uses: ./.github/actions/stage
with:
finished: false
from_artifact: false
x86: true
outputs:
finished: ${{ steps.stage.outputs.finished }}
build-x86-2:
needs: build-x86-1
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Init
run: Copy-Item -Path . -Destination "C:\ungoogled-chromium-windows" -Recurse
- name: Setup Stage
run: npm install
working-directory: ./.github/actions/stage
- name: Run Stage
id: stage
uses: ./.github/actions/stage
with:
finished: ${{ join(needs.*.outputs.finished) }}
from_artifact: true
x86: true
outputs:
finished: ${{ steps.stage.outputs.finished }}
build-x86-3:
needs: build-x86-2
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Init
run: Copy-Item -Path . -Destination "C:\ungoogled-chromium-windows" -Recurse
- name: Setup Stage
run: npm install
working-directory: ./.github/actions/stage
- name: Run Stage
id: stage
uses: ./.github/actions/stage
with:
finished: ${{ join(needs.*.outputs.finished) }}
from_artifact: true
x86: true
outputs:
finished: ${{ steps.stage.outputs.finished }}
build-x86-4:
needs: build-x86-3
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Init
run: Copy-Item -Path . -Destination "C:\ungoogled-chromium-windows" -Recurse
- name: Setup Stage
run: npm install
working-directory: ./.github/actions/stage
- name: Run Stage
id: stage
uses: ./.github/actions/stage
with:
finished: ${{ join(needs.*.outputs.finished) }}
from_artifact: true
x86: true
outputs:
finished: ${{ steps.stage.outputs.finished }}
build-x86-5:
needs: build-x86-4
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Init
run: Copy-Item -Path . -Destination "C:\ungoogled-chromium-windows" -Recurse
- name: Setup Stage
run: npm install
working-directory: ./.github/actions/stage
- name: Run Stage
id: stage
uses: ./.github/actions/stage
with:
finished: ${{ join(needs.*.outputs.finished) }}
from_artifact: true
x86: true
outputs:
finished: ${{ steps.stage.outputs.finished }}
build-x86-6:
needs: build-x86-5
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Init
run: Copy-Item -Path . -Destination "C:\ungoogled-chromium-windows" -Recurse
- name: Setup Stage
run: npm install
working-directory: ./.github/actions/stage
- name: Run Stage
id: stage
uses: ./.github/actions/stage
with:
finished: ${{ join(needs.*.outputs.finished) }}
from_artifact: true
x86: true
outputs:
finished: ${{ steps.stage.outputs.finished }}
publish-release:
needs: [build-6, build-x86-6]
runs-on: ubuntu-latest
steps:
- name: Download package
uses: actions/download-artifact@v2
if: ${{ needs.build-6.outputs.finished == 'true' }}
with:
name: chromium
- name: Download x86 package
uses: actions/download-artifact@v2
if: ${{ needs.build-x86-6.outputs.finished == 'true' }}
with:
name: chromium-x86
- name: Publish release
uses: softprops/action-gh-release@v1
with:
fail_on_unmatched_files: true
files: |
ungoogled-chromium*
Loading

0 comments on commit c57948f

Please sign in to comment.