Skip to content

Commit

Permalink
Add upstream sync & nightly build bot
Browse files Browse the repository at this point in the history
+ experimental build & test on Linux
  • Loading branch information
spectatorBH committed Jan 17, 2024
1 parent cd53ec3 commit 2311a03
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 146 deletions.
22 changes: 10 additions & 12 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
name: Build & Publish (release)
name: Build / Test / Publish on Windows [manual + auto]

on:
workflow_dispatch:
push:
branches:
- test
release:
types:
- created


defaults:
run:
shell: cmd
Expand All @@ -24,44 +21,45 @@ jobs:
- name: Install dependencies into Virtual Environment...
run: _RegisterHelixNUnit.bat

- name: Build project in Release-mode, compile Pas-units, create install packages...
- name: Build project in release-mode, compile Pas-units, create install packages...
run: _GenerateAllSetups.bat
timeout-minutes: 45
#run: _RebuildReleaseAndRunTestsForGitHubActions.bat
timeout-minutes: 40
env:
PABCNET_BUILD_MODE: Release
PABCNET_RUN_TESTS: false
PABCNET_INC_BUILD: false
PABCNET_VERBOSE: false

- name: Publish artifacts (1/4)...
- name: Publish artifact 1/4 [Win7_IDE_Full]
uses: actions/upload-artifact@v4
with:
name: PascalABCNET_Win7_IDE_Full
path: Release/PascalABCNETSetup.exe
if-no-files-found: error

- name: Publish artifacts (2/4)...
- name: Publish artifact 2/4 [Win7_IDE_Mini]
uses: actions/upload-artifact@v4
with:
name: PascalABCNET_Win7_IDE_Mini
path: Release/PascalABCNETMiniSetup.exe
if-no-files-found: error

- name: Publish artifacts (3/4)...
- name: Publish artifact 3/4 [WinXP_IDE_Full]
uses: actions/upload-artifact@v4
with:
name: PascalABCNET_WinXP_IDE_Full
path: Release/PascalABCNETWithDotNet40Setup.exe
if-no-files-found: error

- name: Publish artifacts (4/4)...
- name: Publish artifact 4/4 [Win_Mac_Linux_console]
uses: actions/upload-artifact@v4
with:
name: PascalABCNET_Win_Mac_Linux_console
path: Release/PABCNETC.zip
if-no-files-found: error

#- name: Publish artifacts (5/5)...
#- name: Publish artifact 5/5 [All_distros]
# uses: actions/upload-artifact@v4
# with:
# name: All_distros
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/build-and-run-tests-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build / Test on Ubuntu [manual]

on:
workflow_dispatch:

defaults:
run:
shell: sh

jobs:
build:

name: Prepare and build on Ubuntu
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build project in Release-mode / compile Pas-units / run tests
run: ./_RebuildReleaseAndRunTests.sh
timeout-minutes: 40
env:
PABCNET_BUILD_MODE: Release
PABCNET_RUN_TESTS: false
PABCNET_INC_BUILD: false
PABCNET_VERBOSE: false

74 changes: 0 additions & 74 deletions .github/workflows/build-test-and-publish.yml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/workflows/buildandruntests.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/workflows/buildandruntestslinux.yml

This file was deleted.

141 changes: 141 additions & 0 deletions .github/workflows/make-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Pull upstream / Make a nightly release on Windows [manual + cron]

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: write

defaults:
run:
shell: cmd

jobs:
build:

name: Prepare and build on Windows Server 2019 VM
runs-on: windows-2019
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Pull changes from original repo
run: |
git config --global user.name "BH build bot"
git config --global user.email "SpectatorBH@outlook.com"

git pull https://github.com/pascalabcnet/pascalabcnet.git master
git push

- name: Install dependencies into Virtual Environment
run: _RegisterHelixNUnit.bat

- name: Build C# project in Release-mode / compile Pas-units / run tests
run: _GenerateAllSetupsForGitHubActions.bat
timeout-minutes: 40
env:
PABCNET_BUILD_MODE: Release
PABCNET_RUN_TESTS: false
PABCNET_INC_BUILD: false
PABCNET_VERBOSE: false

- name: Prepare GitHub scripting module
run: npm install @actions/exec

- name: Create GitHub Release
uses: actions/github-script@main
with:
script: |
const tag = "nightly-release-tag"; // Git tag name (preferably different from branch name)
const release_name = "Nightly build (upstream synced)"; // GitHub release display name
const mark_pre_release = true;
console.log('environment', process.versions);
sha = '';
await require('@actions/exec').exec('git', ['rev-parse', 'HEAD'], {
listeners: {
stdout: data => {
sha += data.toString().trim();
},
stderr: data => {
sha += data.toString().trim();
}
}
});
const { repo: { owner, repo } } = context;
console.log({ owner, repo, sha });
// Check if the release already exists
const existingReleases = await github.rest.repos.listReleases({ owner, repo });
for (const existingRelease of existingReleases.data) {
if (existingRelease.tag_name === tag) {
console.log('deleing old release', { existingRelease });
await github.rest.repos.deleteRelease({
owner,
repo,
release_id: existingRelease.id,
});
break;
}
}
try {
await github.rest.git.deleteRef({
owner: owner,
repo: repo,
ref: `tags/${tag}`
});
console.log('Tag deleted successfully');
} catch (error) {
console.error(`Error deleting tag: ${error}`);
}
const release = await github.rest.repos.createRelease({
owner, repo,
tag_name: tag,
name: release_name,
draft: true,
prerelease: mark_pre_release,
target_commitish: sha
});
console.log('created release', { release });
const fs = require('fs').promises;
for (let file of await fs.readdir('Release')) {
console.log('uploading', file);
if (file.startsWith('.')) continue;
try {
await github.rest.repos.uploadReleaseAsset({
owner, repo,
release_id: release.data.id,
name: file,
data: await fs.readFile(`./Release/${file}`)
});
} catch (error) {
console.error(`Error uploading: ${error}`);
}
}
if (release.data.draft) {
console.log('finalizing draft release');
await github.rest.repos.updateRelease({
owner,
repo,
release_id: release.data.id,
draft: false,
});
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"dotnet.preferCSharpExtension": true
"dotnet.preferCSharpExtension": true,
"dotnet.defaultSolution": "disable"
}

0 comments on commit 2311a03

Please sign in to comment.