This repository has been archived on 2022-08-05. You can view files and clone it, but cannot push or open issues or pull requests.
UpTool2/.github/workflows/main.yml

60 lines
2.5 KiB
YAML
Raw Normal View History

2019-11-13 14:34:29 +01:00
name: CD
on: [push]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: Run a multi-line script
run: |
cd "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\"
.\MSBuild.exe $Env:GITHUB_WORKSPACE\UpTool2.sln -p:Configuration=Release -m
2019-11-13 15:02:36 +01:00
cd "C:\Program Files\7-Zip\"
.\7z a $Env:GITHUB_WORKSPACE\Release.zip $Env:GITHUB_WORKSPACE\UpTool2\bin\Release
2019-11-14 18:01:31 +01:00
cd $Env:GITHUB_WORKSPACE\UpTool2\bin\Release
$asmver = $([Reflection.Assembly]::Loadfile($(pwd).Path + "\\UpTool2.exe").GetName().version.ToString())
2019-11-13 14:34:29 +01:00
cd $Env:GITHUB_WORKSPACE
2019-11-13 15:02:36 +01:00
$xml = New-Object XML
$xml.load("Meta.xml")
$xml.meta.Hash = $(Get-FileHash .\Release.zip).Hash
2019-11-14 18:01:31 +01:00
$xml.meta.Version = $asmver
2019-12-11 16:53:54 +01:00
$xml.meta.File = "https://github.com/JFronny/UpTool2/raw/master/Release.zip"
2019-11-13 15:02:36 +01:00
$xml.save("Meta.xml")
2019-11-14 18:19:24 +01:00
# Some copy/pasted code to remove the UTF-8 BOM
$FilePath=$(pwd).Path + "\Meta.xml"
[System.IO.FileInfo] $file = Get-Item -Path $FilePath
$sequenceBOM = New-Object System.Byte[] 3
$reader = $file.OpenRead()
$bytesRead = $reader.Read($sequenceBOM, 0, 3)
$reader.Dispose()
if ($bytesRead -eq 3 -and $sequenceBOM[0] -eq 239 -and $sequenceBOM[1] -eq 187 -and $sequenceBOM[2] -eq 191)
{
$utf8NoBomEncoding = New-Object System.Text.UTF8Encoding($False)
[System.IO.File]::WriteAllLines($FilePath, (Get-Content $FilePath), $utf8NoBomEncoding)
Write-Host "Remove UTF-8 BOM successfully"
}
2019-12-19 20:46:42 +01:00
- name: Create Release
id: create_release
uses: actions/create-release@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2019-11-13 14:34:29 +01:00
with:
2019-12-19 20:46:42 +01:00
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./$Env:GITHUB_WORKSPACE\Release.zip
asset_name: Release.zip
asset_content_type: application/zip