-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/LiuYunPlayer/TuneLab
- Loading branch information
Showing
3 changed files
with
208 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,22 +5,31 @@ name: Build artifacts | |
on: | ||
push: | ||
branches: [ "master" ] | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: [ "master" ] | ||
workflow_call: | ||
|
||
jobs: | ||
|
||
build-windows: | ||
name: Build Windows version | ||
build: | ||
runs-on: ${{matrix.os}} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
runtime: [ "win-x64" ] | ||
|
||
runs-on: windows-latest | ||
|
||
runtime: [ "win-x64", "osx-arm64", "linux-x64" ] | ||
include: | ||
- runtime: "win-x64" | ||
os: "windows-latest" | ||
- runtime: "osx-arm64" | ||
os: "macos-latest" | ||
- runtime: "linux-x64" | ||
os: "ubuntu-latest" | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
attestations: write | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
@@ -35,163 +44,36 @@ jobs: | |
- name: Build the application | ||
run: dotnet publish --configuration Release -r ${{ matrix.runtime }} | ||
|
||
- name: Set short SHA as package name | ||
if: "!startsWith(github.event.ref, 'refs/tags/')" | ||
run: echo "ARCHIVE_NAME=TuneLab-${{ matrix.runtime }}-$(git rev-parse --short HEAD)" >> $env:GITHUB_ENV | ||
|
||
- name: Set tag version into env | ||
if: startsWith(github.event.ref, 'refs/tags/') | ||
run: echo "TAG_NAME=${env:GITHUB_REF_NAME}" >> $env:GITHUB_ENV | ||
|
||
- name: Set tag version as package name | ||
if: startsWith(github.event.ref, 'refs/tags/') | ||
run: echo "ARCHIVE_NAME=TuneLab-${{ matrix.runtime }}-${env:TAG_NAME}" >> $env:GITHUB_ENV | ||
|
||
- name: Move artifacts | ||
- name: Move artifacts - Windows | ||
if: runner.os == 'Windows' | ||
shell: pwsh | ||
run: Move-Item -Path TuneLab\bin\Release\net8.0\${{ matrix.runtime }}\publish -Destination workspace | ||
|
||
- name: Pack artifacts | ||
shell: pwsh | ||
run: Compress-Archive -Path workspace\* -DestinationPath ${env:ARCHIVE_NAME}'.zip' | ||
|
||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.ARCHIVE_NAME }} | ||
path: workspace | ||
|
||
- name: Upload release artifacts | ||
if: startsWith(github.event.ref, 'refs/tags/') | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.ARCHIVE_NAME }}.zip | ||
path: ${{ env.ARCHIVE_NAME }}.zip | ||
retention-days: 1 | ||
|
||
|
||
build-macos: | ||
name: Build macOS version | ||
|
||
strategy: | ||
matrix: | ||
runtime: [ "osx-arm64" ] | ||
|
||
runs-on: macos-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install .NET Core | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: 8.0.x | ||
|
||
- name: Build the application | ||
run: dotnet publish --configuration Release -r ${{ matrix.runtime }} | ||
|
||
- name: Set short SHA as package name | ||
if: "!startsWith(github.event.ref, 'refs/tags/')" | ||
run: echo "ARCHIVE_NAME=TuneLab-${{ matrix.runtime }}-$(git rev-parse --short HEAD)" >> $GITHUB_ENV | ||
|
||
- name: Set tag version into env | ||
if: startsWith(github.event.ref, 'refs/tags/') | ||
run: echo "TAG_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV | ||
|
||
- name: Set tag version as package name | ||
if: startsWith(github.event.ref, 'refs/tags/') | ||
run: echo "ARCHIVE_NAME=TuneLab-${{ matrix.runtime }}-$TAG_NAME" >> $GITHUB_ENV | ||
|
||
- name: Move artifacts | ||
- name: Move artifacts - MacOS and Linux | ||
if: runner.os != 'Windows' | ||
run: mv TuneLab/bin/Release/net8.0/${{ matrix.runtime }}/publish workspace | ||
|
||
- name: Pack artifacts | ||
run: | | ||
cd workspace | ||
tar -zcvf ../$ARCHIVE_NAME.tar.gz . | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
- name: Generate artifact attestation - Windows | ||
if: runner.os == 'Windows' && github.event_name != 'pull_request' | ||
uses: actions/attest-build-provenance@v1 | ||
with: | ||
name: ${{ env.ARCHIVE_NAME }}.tar.gz | ||
path: ${{ env.ARCHIVE_NAME }}.tar.gz | ||
subject-path: '"workspace/*.dll","workspace/*.exe"' | ||
|
||
|
||
build-linux: | ||
name: Build Linux version | ||
|
||
strategy: | ||
matrix: | ||
runtime: [ "linux-x64" ] | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Generate artifact attestation - MacOS and Linux | ||
if: runner.os != 'Windows' && github.event_name != 'pull_request' | ||
uses: actions/attest-build-provenance@v1 | ||
with: | ||
fetch-depth: 0 | ||
subject-path: '"workspace/*.dll","workspace/ExtensionInstaller","workspace/TuneLab"' | ||
|
||
- name: Install .NET Core | ||
uses: actions/setup-dotnet@v4 | ||
- name: Get short SHA | ||
uses: benjlevesque/[email protected] | ||
id: short-sha | ||
with: | ||
dotnet-version: 8.0.x | ||
|
||
- name: Build the application | ||
run: dotnet publish --configuration Release -r ${{ matrix.runtime }} | ||
|
||
- name: Set short SHA as package name | ||
if: "!startsWith(github.event.ref, 'refs/tags/')" | ||
run: echo "ARCHIVE_NAME=TuneLab-${{ matrix.runtime }}-$(git rev-parse --short HEAD)" >> $GITHUB_ENV | ||
|
||
- name: Set tag version into env | ||
if: startsWith(github.event.ref, 'refs/tags/') | ||
run: echo "TAG_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV | ||
|
||
- name: Set tag version as package name | ||
if: startsWith(github.event.ref, 'refs/tags/') | ||
run: echo "ARCHIVE_NAME=TuneLab-${{ matrix.runtime }}-$TAG_NAME" >> $GITHUB_ENV | ||
|
||
- name: Move artifacts | ||
run: mv TuneLab/bin/Release/net8.0/${{ matrix.runtime }}/publish workspace | ||
|
||
- name: Pack artifacts | ||
run: | | ||
cd workspace | ||
tar -zcvf ../$ARCHIVE_NAME.tar.gz . | ||
length: 7 | ||
|
||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.ARCHIVE_NAME }}.tar.gz | ||
path: ${{ env.ARCHIVE_NAME }}.tar.gz | ||
|
||
|
||
prepare-release: | ||
name: Prepare release | ||
if: startsWith(github.event.ref, 'refs/tags/') | ||
needs: | ||
- build-windows | ||
- build-macos | ||
- build-linux | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
merge-multiple: true | ||
name: TuneLab-${{ matrix.runtime }}-${{ steps.short-sha.outputs.sha }} | ||
path: workspace | ||
|
||
- name: Create release (draft) | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
name: TuneLab - ${{ github.ref_name }} | ||
generate_release_notes: true | ||
draft: true | ||
files: | | ||
TuneLab-*.zip | ||
# TuneLab-*.tar.gz # 因为还没有解决跨平台的问题所以这个先注释掉,等跨平台完成了就可以去掉这个注释一并发布 linux 和 osx 的版本了 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
name: Upload release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
call-build: | ||
uses: ./.github/workflows/build-artifacts.yml | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
attestations: write | ||
|
||
create-release: | ||
name: Create release | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Generate release notes | ||
id: notes | ||
uses: RedCrafter07/[email protected] | ||
with: | ||
tag-name: ${{ github.ref }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: 'master' | ||
|
||
- name: Create release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: TuneLab ${{ github.ref }} | ||
body: ${{ steps.notes.outputs.release-notes }} | ||
draft: false | ||
prerelease: false | ||
|
||
release: | ||
name: Upload release | ||
needs: [call-build, create-release] | ||
runs-on: ${{matrix.os}} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
runtime: [ "win-x64", "osx-arm64", "linux-x64" ] | ||
include: | ||
- runtime: "win-x64" | ||
os: "windows-latest" | ||
- runtime: "osx-arm64" | ||
os: "macos-latest" | ||
- runtime: "linux-x64" | ||
os: "ubuntu-latest" | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Get short SHA | ||
uses: benjlevesque/[email protected] | ||
id: short-sha | ||
with: | ||
length: 7 | ||
|
||
- name: Download artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: TuneLab-${{ matrix.runtime }}-${{ steps.short-sha.outputs.sha }} | ||
|
||
- name: Package - Windows | ||
if: runner.os == 'Windows' | ||
shell: pwsh | ||
working-directory: ${{github.workspace}} | ||
run: Compress-Archive -Path .\* -DestinationPath package.zip | ||
|
||
- name: Package - MacOS and Linux | ||
if: runner.os != 'Windows' | ||
working-directory: ${{github.workspace}} | ||
run: tar -zcvf package.tar.gz ./* | ||
|
||
- name: Upload - Windows | ||
if: runner.os == 'Windows' | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ needs.create-release.outputs.upload_url }} | ||
asset_path: ./package.zip | ||
asset_name: TuneLab-${{ matrix.runtime }}-${{ github.ref_name }}.zip | ||
asset_content_type: application/zip | ||
|
||
# 因为还没有解决跨平台的问题所以这个先关掉掉,等跨平台完成了就可以去掉执行条件里的 false 一并发布 linux 和 osx 的版本了 | ||
- name: Upload - MacOS and Linux | ||
if: runner.os != 'Windows' && false | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ needs.create-release.outputs.upload_url }} | ||
asset_path: ./package.tar.gz | ||
asset_name: TuneLab-${{ matrix.runtime }}-${{ github.ref_name }}.tar.gz | ||
asset_content_type: application/gzip |
Oops, something went wrong.