gha: Add steps to upload nupkg as artifact & publish to Nuget
This commit is contained in:
47
.github/workflows/Nuget-publishing.yml
vendored
47
.github/workflows/Nuget-publishing.yml
vendored
@@ -124,7 +124,7 @@ jobs:
|
|||||||
|
|
||||||
- name: '📤 Upload artifact'
|
- name: '📤 Upload artifact'
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v1
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
path: ./${{ matrix.config.artifact }}
|
path: ./${{ matrix.config.artifact }}
|
||||||
name: ${{ matrix.config.artifact }}
|
name: ${{ matrix.config.artifact }}
|
||||||
@@ -182,7 +182,7 @@ jobs:
|
|||||||
|
|
||||||
- name: '📤 Upload artifact'
|
- name: '📤 Upload artifact'
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v1
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
path: ./${{ matrix.config.artifact }}
|
path: ./${{ matrix.config.artifact }}
|
||||||
name: ${{ matrix.config.artifact }}
|
name: ${{ matrix.config.artifact }}
|
||||||
@@ -251,9 +251,9 @@ jobs:
|
|||||||
shell: 'script -q -e -c "bash {0}"'
|
shell: 'script -q -e -c "bash {0}"'
|
||||||
run: |
|
run: |
|
||||||
if [ ${{ matrix.config.arch }} == 'x64' ]; then
|
if [ ${{ matrix.config.arch }} == 'x64' ]; then
|
||||||
sudo apt install -q -y libcmocka-dev ninja-build
|
sudo apt install -q -y libcmocka-dev ninja-build
|
||||||
else
|
else
|
||||||
export CFLAGS="-m32" LDFLAGS="-m32" LDFLAGS_STATIC="-m32" UNICORN_QEMU_FLAGS="--cpu=i386"
|
export CFLAGS="-m32" LDFLAGS="-m32" LDFLAGS_STATIC="-m32" UNICORN_QEMU_FLAGS="--cpu=i386"
|
||||||
sudo dpkg --add-architecture i386
|
sudo dpkg --add-architecture i386
|
||||||
sudo apt install -q -y lib32ncurses-dev lib32z1-dev lib32gcc-9-dev libc6-dev-i386 gcc-multilib \
|
sudo apt install -q -y lib32ncurses-dev lib32z1-dev lib32gcc-9-dev libc6-dev-i386 gcc-multilib \
|
||||||
libcmocka-dev:i386 libcmocka0:i386 libc6:i386 libgcc-s1:i386 ninja-build
|
libcmocka-dev:i386 libcmocka0:i386 libc6:i386 libgcc-s1:i386 ninja-build
|
||||||
@@ -307,7 +307,7 @@ jobs:
|
|||||||
|
|
||||||
- name: '📤 Upload artifact'
|
- name: '📤 Upload artifact'
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v1
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
path: ./${{ matrix.config.artifact }}
|
path: ./${{ matrix.config.artifact }}
|
||||||
name: ${{ matrix.config.artifact }}
|
name: ${{ matrix.config.artifact }}
|
||||||
@@ -320,20 +320,20 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Download artifacts
|
- name: 🛠️ Download artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: artifacts
|
path: artifacts
|
||||||
|
|
||||||
- name: Extract artifacts
|
- name: 🛠️ Extract artifacts
|
||||||
shell: python
|
shell: python
|
||||||
run: |
|
run: |
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
|
|
||||||
artifactPath = os.path.join(os.getcwd(), "artifacts")
|
artifactPath = os.path.join(os.getcwd(), "artifacts")
|
||||||
bindingsPath = os.path.join(os.getcwd(), "bindings", "dotnet", "UnicornEngine")
|
bindingsPath = os.path.join(os.getcwd(), "bindings", "dotnet", "UnicornEngine")
|
||||||
|
|
||||||
ARTIFACT_CONFIG = {
|
ARTIFACT_CONFIG = {
|
||||||
"ubuntu-cmake-aarch64.7z": {
|
"ubuntu-cmake-aarch64.7z": {
|
||||||
"sourceDir": "lib/",
|
"sourceDir": "lib/",
|
||||||
@@ -372,11 +372,11 @@ jobs:
|
|||||||
"destFile": "unicorn.dll"
|
"destFile": "unicorn.dll"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(os.listdir(artifactPath)) < len(ARTIFACT_CONFIG.keys()):
|
if len(os.listdir(artifactPath)) < len(ARTIFACT_CONFIG.keys()):
|
||||||
print("Some artifacts are missing. Aborting.")
|
print("Some artifacts are missing. Aborting.")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
for artifact in os.listdir(artifactPath):
|
for artifact in os.listdir(artifactPath):
|
||||||
if artifact in ARTIFACT_CONFIG.keys():
|
if artifact in ARTIFACT_CONFIG.keys():
|
||||||
print("Working on:", artifact)
|
print("Working on:", artifact)
|
||||||
@@ -384,20 +384,20 @@ jobs:
|
|||||||
destDir = os.path.join(bindingsPath, config["destDir"])
|
destDir = os.path.join(bindingsPath, config["destDir"])
|
||||||
print("Creating dir:", destDir)
|
print("Creating dir:", destDir)
|
||||||
os.makedirs(destDir, exist_ok=True)
|
os.makedirs(destDir, exist_ok=True)
|
||||||
|
|
||||||
print(f"Extracting library from 7z file to: {config['destDir']}/{config['sourceFile']}")
|
print(f"Extracting library from 7z file to: {config['destDir']}/{config['sourceFile']}")
|
||||||
result = subprocess.run(["7z", "e", f"-o{destDir}/", os.path.join(artifactPath, artifact), f"{config['sourceDir']}{config['sourceFile']}"])
|
result = subprocess.run(["7z", "e", f"-o{destDir}/", os.path.join(artifactPath, artifact), f"{config['sourceDir']}{config['sourceFile']}"])
|
||||||
result.check_returncode()
|
result.check_returncode()
|
||||||
|
|
||||||
if config["sourceFile"] != config["destFile"]:
|
if config["sourceFile"] != config["destFile"]:
|
||||||
output = subprocess.run(["ls", destDir], stdout=subprocess.PIPE)
|
output = subprocess.run(["ls", destDir], stdout=subprocess.PIPE)
|
||||||
sourceFile = output.stdout.decode().strip()
|
sourceFile = output.stdout.decode().strip()
|
||||||
print(f"Renaming {sourceFile} to {config['destFile']}")
|
print(f"Renaming {sourceFile} to {config['destFile']}")
|
||||||
os.rename(os.path.join(destDir, sourceFile), os.path.join(destDir, config["destFile"]))
|
os.rename(os.path.join(destDir, sourceFile), os.path.join(destDir, config["destFile"]))
|
||||||
|
|
||||||
print("Done!")
|
print("Done!")
|
||||||
|
|
||||||
- name: Get short sha
|
- name: 🛠️ Get short sha
|
||||||
id: git_short_sha
|
id: git_short_sha
|
||||||
run: echo "result=$(git rev-parse --short "${{ github.sha }}")" >> $GITHUB_OUTPUT
|
run: echo "result=$(git rev-parse --short "${{ github.sha }}")" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
@@ -405,21 +405,32 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
dotnet-version: 6.0.x
|
dotnet-version: 6.0.x
|
||||||
|
|
||||||
- name: Authenticate to Github Packages
|
- name: 🛠️ Authenticate to Github Packages
|
||||||
working-directory: bindings/dotnet/UnicornEngine
|
working-directory: bindings/dotnet/UnicornEngine
|
||||||
run: dotnet nuget add source --username "${{ github.repository_owner }}" --password "${{ secrets.GITHUB_TOKEN }}" --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
|
run: dotnet nuget add source --username "${{ github.repository_owner }}" --password "${{ secrets.GITHUB_TOKEN }}" --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
|
||||||
|
|
||||||
- name: List all native libraries
|
- name: 🛠️ List all native libraries
|
||||||
working-directory: bindings/dotnet/UnicornEngine
|
working-directory: bindings/dotnet/UnicornEngine
|
||||||
run: find ./runtimes -type f -print
|
run: find ./runtimes -type f -print
|
||||||
|
|
||||||
- name: Package .NET distribution
|
- name: 🚧 Package .NET distribution
|
||||||
working-directory: bindings/dotnet/UnicornEngine
|
working-directory: bindings/dotnet/UnicornEngine
|
||||||
run: |
|
run: |
|
||||||
[[ "${{ github.ref_name }}" == "master" ]] \
|
[[ "${{ github.ref_name }}" == "master" ]] \
|
||||||
&& dotnet pack -c Release \
|
&& dotnet pack -c Release \
|
||||||
|| dotnet pack -c Release --version-suffix="${{ steps.git_short_sha.outputs.result }}"
|
|| dotnet pack -c Release --version-suffix="${{ steps.git_short_sha.outputs.result }}"
|
||||||
|
|
||||||
|
- name: '📤 Upload artifact'
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
path: ${{ github.workspace }}/bindings/dotnet/UnicornEngine/bin/Release/UnicornEngine.Unicorn.*.nupkg
|
||||||
|
|
||||||
- name: 📦 Publish to Github Packages
|
- name: 📦 Publish to Github Packages
|
||||||
working-directory: bindings/dotnet/UnicornEngine
|
working-directory: bindings/dotnet/UnicornEngine
|
||||||
run: dotnet nuget push "bin/Release/UnicornEngine.Unicorn.*.nupkg" --source "github" --api-key "${{ secrets.GHPR_TOKEN }}"
|
run: dotnet nuget push "bin/Release/UnicornEngine.Unicorn.*.nupkg" --source "github" --api-key "${{ secrets.GHPR_TOKEN }}"
|
||||||
|
|
||||||
|
- name: 📦 Publish Nuget package
|
||||||
|
working-directory: bindings/dotnet/UnicornEngine
|
||||||
|
run: dotnet nuget push "bin/Release/UnicornEngine.Unicorn.*.nupkg" -k "$NUGET_AUTH_TOKEN" -s https://api.nuget.org/v3/index.json
|
||||||
|
env:
|
||||||
|
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_KEY }}
|
||||||
|
|||||||
Reference in New Issue
Block a user