mirror of
https://github.com/par274/sharpemu.git
synced 2026-07-16 00:40:59 +00:00
[CI] Update for cross-platform support
This commit is contained in:
93
.github/workflows/workflow.yml
vendored
93
.github/workflows/workflow.yml
vendored
@@ -34,31 +34,31 @@ jobs:
|
|||||||
name: Init
|
name: Init
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
archive-name: ${{ steps.vars.outputs.archive-name }}
|
|
||||||
artifact-name: ${{ steps.vars.outputs.artifact-name }}
|
|
||||||
release-name: ${{ steps.vars.outputs.release-name }}
|
release-name: ${{ steps.vars.outputs.release-name }}
|
||||||
release-tag: ${{ steps.vars.outputs.release-tag }}
|
release-tag: ${{ steps.vars.outputs.release-tag }}
|
||||||
safe-ref: ${{ steps.vars.outputs.safe-ref }}
|
safe-ref: ${{ steps.vars.outputs.safe-ref }}
|
||||||
short-sha: ${{ steps.vars.outputs.short-sha }}
|
short-sha: ${{ steps.vars.outputs.short-sha }}
|
||||||
|
version: ${{ steps.vars.outputs.version }}
|
||||||
steps:
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Compute workflow variables
|
- name: Compute workflow variables
|
||||||
id: vars
|
id: vars
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
short_sha="${GITHUB_SHA::7}"
|
short_sha="${GITHUB_SHA::7}"
|
||||||
safe_ref="$(echo "${GITHUB_REF_NAME}" | tr '[:upper:]' '[:lower:]' | sed 's#[^a-z0-9._-]#-#g')"
|
safe_ref="$(echo "${GITHUB_REF_NAME}" | tr '[:upper:]' '[:lower:]' | sed 's#[^a-z0-9._-]#-#g')"
|
||||||
archive_name="sharpemu-win64-${short_sha}.zip"
|
version="$(python3 -c 'import sys, xml.etree.ElementTree as ET; version = ET.parse("Directory.Build.props").getroot().findtext(".//SharpEmuVersion"); sys.exit("Directory.Build.props is missing SharpEmuVersion") if not version or not version.strip() else print(version.strip())')"
|
||||||
artifact_name="sharpemu-win64-${short_sha}"
|
release_tag="v${version}"
|
||||||
release_tag="win64-${safe_ref}-${short_sha}"
|
release_name="SharpEmu v${version}"
|
||||||
release_name="SharpEmu win64 ${short_sha}"
|
|
||||||
|
|
||||||
{
|
{
|
||||||
echo "short-sha=${short_sha}"
|
echo "short-sha=${short_sha}"
|
||||||
echo "safe-ref=${safe_ref}"
|
echo "safe-ref=${safe_ref}"
|
||||||
echo "archive-name=${archive_name}"
|
|
||||||
echo "artifact-name=${artifact_name}"
|
|
||||||
echo "release-tag=${release_tag}"
|
echo "release-tag=${release_tag}"
|
||||||
echo "release-name=${release_name}"
|
echo "release-name=${release_name}"
|
||||||
|
echo "version=${version}"
|
||||||
} >> "$GITHUB_OUTPUT"
|
} >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
reuse:
|
reuse:
|
||||||
@@ -73,7 +73,7 @@ jobs:
|
|||||||
uses: fsfe/reuse-action@v6
|
uses: fsfe/reuse-action@v6
|
||||||
|
|
||||||
build:
|
build:
|
||||||
name: Build Archive
|
name: Build win-x64
|
||||||
needs:
|
needs:
|
||||||
- init
|
- init
|
||||||
- reuse
|
- reuse
|
||||||
@@ -112,7 +112,8 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
New-Item -ItemType Directory -Path $env:RELEASE_DIR -Force | Out-Null
|
New-Item -ItemType Directory -Path $env:RELEASE_DIR -Force | Out-Null
|
||||||
|
|
||||||
$archivePath = Join-Path $env:RELEASE_DIR "${{ needs.init.outputs.archive-name }}"
|
$archiveName = "sharpemu-${{ needs.init.outputs.version }}-win-x64-${{ needs.init.outputs.short-sha }}.zip"
|
||||||
|
$archivePath = Join-Path $env:RELEASE_DIR $archiveName
|
||||||
if (Test-Path $archivePath) {
|
if (Test-Path $archivePath) {
|
||||||
Remove-Item $archivePath -Force
|
Remove-Item $archivePath -Force
|
||||||
}
|
}
|
||||||
@@ -122,8 +123,8 @@ jobs:
|
|||||||
- name: Upload build artifact
|
- name: Upload build artifact
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: ${{ needs.init.outputs.artifact-name }}
|
name: sharpemu-win-x64-${{ needs.init.outputs.short-sha }}
|
||||||
path: ${{ env.RELEASE_DIR }}\${{ needs.init.outputs.archive-name }}
|
path: ${{ env.RELEASE_DIR }}\sharpemu-${{ needs.init.outputs.version }}-win-x64-${{ needs.init.outputs.short-sha }}.zip
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
build-posix:
|
build-posix:
|
||||||
@@ -175,14 +176,14 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir -p "$RELEASE_DIR"
|
mkdir -p "$RELEASE_DIR"
|
||||||
# tar keeps the executable bit, which zip would drop.
|
# tar keeps the executable bit, which zip would drop.
|
||||||
tar -czf "$RELEASE_DIR/sharpemu-${{ matrix.rid }}-${{ needs.init.outputs.short-sha }}.tar.gz" \
|
tar -czf "$RELEASE_DIR/sharpemu-${{ needs.init.outputs.version }}-${{ matrix.rid }}-${{ needs.init.outputs.short-sha }}.tar.gz" \
|
||||||
-C "$PUBLISH_DIR" .
|
-C "$PUBLISH_DIR" .
|
||||||
|
|
||||||
- name: Upload build artifact
|
- name: Upload build artifact
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: sharpemu-${{ matrix.rid }}-${{ needs.init.outputs.short-sha }}
|
name: sharpemu-${{ matrix.rid }}-${{ needs.init.outputs.short-sha }}
|
||||||
path: ${{ env.RELEASE_DIR }}/sharpemu-${{ matrix.rid }}-${{ needs.init.outputs.short-sha }}.tar.gz
|
path: ${{ env.RELEASE_DIR }}/sharpemu-${{ needs.init.outputs.version }}-${{ matrix.rid }}-${{ needs.init.outputs.short-sha }}.tar.gz
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
release:
|
release:
|
||||||
@@ -190,77 +191,39 @@ jobs:
|
|||||||
needs:
|
needs:
|
||||||
- init
|
- init
|
||||||
- build
|
- build
|
||||||
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
steps:
|
|
||||||
- name: Download build artifact
|
|
||||||
uses: actions/download-artifact@v8
|
|
||||||
with:
|
|
||||||
name: ${{ needs.init.outputs.artifact-name }}
|
|
||||||
path: release
|
|
||||||
|
|
||||||
- name: Create or update release
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
ARCHIVE_NAME: ${{ needs.init.outputs.archive-name }}
|
|
||||||
GH_REPO: ${{ github.repository }}
|
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
RELEASE_NAME: ${{ needs.init.outputs.release-name }}
|
|
||||||
RELEASE_TAG: ${{ needs.init.outputs.release-tag }}
|
|
||||||
run: |
|
|
||||||
asset_path="release/${ARCHIVE_NAME}"
|
|
||||||
notes="Automated Windows build for commit ${GITHUB_SHA}."
|
|
||||||
|
|
||||||
if gh release view "${RELEASE_TAG}" >/dev/null 2>&1; then
|
|
||||||
gh release upload "${RELEASE_TAG}" "${asset_path}" --clobber
|
|
||||||
gh release edit "${RELEASE_TAG}" --title "${RELEASE_NAME}" --notes "${notes}"
|
|
||||||
else
|
|
||||||
gh release create "${RELEASE_TAG}" "${asset_path}" \
|
|
||||||
--title "${RELEASE_NAME}" \
|
|
||||||
--notes "${notes}" \
|
|
||||||
--target "${GITHUB_SHA}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
release-posix:
|
|
||||||
name: Publish GitHub Release (${{ matrix.rid }})
|
|
||||||
needs:
|
|
||||||
- init
|
|
||||||
- build-posix
|
- build-posix
|
||||||
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
|
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
rid: [linux-x64, osx-x64]
|
|
||||||
steps:
|
steps:
|
||||||
- name: Download build artifact
|
- name: Download build artifacts
|
||||||
uses: actions/download-artifact@v8
|
uses: actions/download-artifact@v8
|
||||||
with:
|
with:
|
||||||
name: sharpemu-${{ matrix.rid }}-${{ needs.init.outputs.short-sha }}
|
|
||||||
path: release
|
path: release
|
||||||
|
|
||||||
- name: Create or update release
|
- name: Create or update release
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
ARCHIVE_NAME: sharpemu-${{ matrix.rid }}-${{ needs.init.outputs.short-sha }}.tar.gz
|
|
||||||
GH_REPO: ${{ github.repository }}
|
GH_REPO: ${{ github.repository }}
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
RELEASE_NAME: SharpEmu ${{ matrix.rid }} ${{ needs.init.outputs.short-sha }}
|
RELEASE_NAME: ${{ needs.init.outputs.release-name }}
|
||||||
RELEASE_TAG: ${{ matrix.rid }}-${{ needs.init.outputs.safe-ref }}-${{ needs.init.outputs.short-sha }}
|
RELEASE_TAG: ${{ needs.init.outputs.release-tag }}
|
||||||
RID: ${{ matrix.rid }}
|
VERSION: ${{ needs.init.outputs.version }}
|
||||||
run: |
|
run: |
|
||||||
asset_path="release/${ARCHIVE_NAME}"
|
mapfile -t assets < <(find release -type f \( -name '*.zip' -o -name '*.tar.gz' \) | sort)
|
||||||
notes="Automated ${RID} build for commit ${GITHUB_SHA}."
|
if [ "${#assets[@]}" -eq 0 ]; then
|
||||||
|
echo "No release assets found." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
notes="Automated SharpEmu v${VERSION} build for commit ${GITHUB_SHA}."
|
||||||
|
|
||||||
if gh release view "${RELEASE_TAG}" >/dev/null 2>&1; then
|
if gh release view "${RELEASE_TAG}" >/dev/null 2>&1; then
|
||||||
gh release upload "${RELEASE_TAG}" "${asset_path}" --clobber
|
gh release upload "${RELEASE_TAG}" "${assets[@]}" --clobber
|
||||||
gh release edit "${RELEASE_TAG}" --title "${RELEASE_NAME}" --notes "${notes}"
|
gh release edit "${RELEASE_TAG}" --title "${RELEASE_NAME}" --notes "${notes}"
|
||||||
else
|
else
|
||||||
gh release create "${RELEASE_TAG}" "${asset_path}" \
|
gh release create "${RELEASE_TAG}" "${assets[@]}" \
|
||||||
--title "${RELEASE_NAME}" \
|
--title "${RELEASE_NAME}" \
|
||||||
--notes "${notes}" \
|
--notes "${notes}" \
|
||||||
--target "${GITHUB_SHA}"
|
--target "${GITHUB_SHA}"
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||||
|
<SharpEmuVersion>0.0.1</SharpEmuVersion>
|
||||||
|
<Version>$(SharpEmuVersion)</Version>
|
||||||
|
|
||||||
<RepoRoot>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)'))</RepoRoot>
|
<RepoRoot>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)'))</RepoRoot>
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
|
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<Version>0.0.1</Version>
|
|
||||||
<ServerGarbageCollection>true</ServerGarbageCollection>
|
<ServerGarbageCollection>true</ServerGarbageCollection>
|
||||||
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
|
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
|
||||||
<TieredPGO>true</TieredPGO>
|
<TieredPGO>true</TieredPGO>
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
the executable is started without arguments. -->
|
the executable is started without arguments. -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<GenerateDocumentationFile>false</GenerateDocumentationFile>
|
<GenerateDocumentationFile>false</GenerateDocumentationFile>
|
||||||
<Version>0.0.1</Version>
|
|
||||||
<!-- Required by the source-generated LibraryImport stubs in the linked
|
<!-- Required by the source-generated LibraryImport stubs in the linked
|
||||||
controller readers below. -->
|
controller readers below. -->
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
|||||||
Reference in New Issue
Block a user