Fix published release assets to not have nested folders #26
Workflow file for this run
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
# This workflow will build a .NET project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
name: Build and test | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
version: | |
name: Get version | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.get_version.outputs.version }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Get all tags | |
- name: Get release version | |
id: get_release_version | |
uses: paulhatch/[email protected] | |
with: | |
tag_prefix: "v" | |
version_format: "${major}.${minor}.${patch}" | |
- name: Get branch names | |
id: branch_names | |
uses: OctopusDeploy/util-actions/[email protected] | |
- name: Get pre-release version | |
id: get_pre_release_version | |
uses: paulhatch/[email protected] | |
with: | |
tag_prefix: "v" | |
version_format: "${major}.${minor}.${patch}-${{ steps.branch_names.outputs.branch_name }}.${{ github.run_number }}-${{ github.run_attempt }}" | |
- name: Get version | |
id: get_version | |
run: echo "version=${{ github.ref == 'refs/heads/main' && github.event_name == 'push' && steps.get_release_version.outputs.version || steps.get_pre_release_version.outputs.version }}" >> $GITHUB_OUTPUT | |
build: | |
needs: version | |
strategy: | |
matrix: | |
include: | |
- name: Linux | |
os: ubuntu-latest | |
runtime-id: linux-x64 | |
artifact-name: linux-x64 | |
- name: Windows | |
os: windows-latest | |
runtime-id: win-x64 | |
artifact-name: windows-x64 | |
- name: macOS | |
os: macos-latest | |
runtime-id: osx-x64 | |
artifact-name: macos-x64 | |
name: Build and test on ${{ matrix.name }} | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
working-directory: src | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore -c Release | |
- name: Test | |
run: dotnet test --no-build -c Release --verbosity normal | |
- name: Publish | |
run: dotnet publish Stack/Stack.csproj -c Release -r ${{ matrix.runtime-id }} -p:Version=${{ needs.version.outputs.version }} -p:DebugType=None -p:DebugSymbols=false -o ${{ github.workspace }}/publish | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
overwrite: true | |
name: ${{ matrix.artifact-name }} | |
path: ${{ github.workspace }}/publish | |
publish: | |
name: Publish | |
needs: [version, build] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Download linux artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: linux-x64 | |
path: ${{ github.workspace }}/artifacts/linux-x64 | |
- name: Download windows artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: windows-x64 | |
path: ${{ github.workspace }}/artifacts/windows-x64 | |
- name: Download macOS artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: macos-x64 | |
path: ${{ github.workspace }}/artifacts/macos-x64 | |
- run: mkdir -p ${{ github.workspace }}/publish | |
- name: Zip linux artifact | |
run: zip ${{ github.workspace }}/publish/linux-x64.zip stack | |
working-directory: ${{ github.workspace }}/artifacts/linux-x64 | |
- name: Zip windows artifact | |
run: zip ${{ github.workspace }}/publish/windows-x64.zip stack.exe | |
working-directory: ${{ github.workspace }}/artifacts/windows-x64 | |
- name: Zip macOS artifact | |
run: zip ${{ github.workspace }}/publish/macos-x64.zip stack | |
working-directory: ${{ github.workspace }}/artifacts/macos-x64 | |
- name: Unzip artifacts | |
run: | | |
unzip ${{ github.workspace }}/publish/linux-x64.zip -d ${{ github.workspace }}/unzipped/linux-x64 | |
unzip ${{ github.workspace }}/publish/windows-x64.zip -d ${{ github.workspace }}/unzipped/windows-x64 | |
unzip ${{ github.workspace }}/publish/macos-x64.zip -d ${{ github.workspace }}/unzipped/macos-x64 | |
- name: List unzipped artifacts | |
run: ls -R ${{ github.workspace }}/unzipped | |
- name: List published artifacts | |
run: ls -R ${{ github.workspace }}/publish | |
- name: Create tag | |
uses: actions/[email protected] | |
with: | |
script: | | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: 'refs/tags/v${{ needs.version.outputs.version }}', | |
sha: context.sha | |
}) | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
- name: Create release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: v${{ needs.version.outputs.version }} | |
draft: false | |
prerelease: false | |
files: ${{ github.workspace }}/publish/* | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' |