Skip to content

Commit

Permalink
Simplified pack and publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilia-Kosenkov authored Jan 12, 2021
1 parent cc4bd02 commit eb07c99
Showing 1 changed file with 32 additions and 68 deletions.
100 changes: 32 additions & 68 deletions .github/workflows/pack_and_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
jobs:
build:
build_pack:

runs-on: ubuntu-latest

Expand All @@ -27,72 +27,36 @@ jobs:
- name: Test
run: dotnet test --no-restore --verbosity normal

pack:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.100
- name: Pack library
run: dotnet pack -o ./Packed -c Release -p:Deterministic=true
- uses: actions/[email protected]
with:
name: PackedLibrary
path: ./Packed
publish:
runs-on: ubuntu-latest
needs: pack
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.100
- name: Download package
uses: actions/[email protected]
with:
name: PackedLibrary
path: ./Packed
- name: Publish to github package registry
run: dotnet nuget push -s 'https://nuget.pkg.github.com/Ilia-Kosenkov/index.json' -k $GITHUB_TOKEN --skip-duplicate ./Packed/*nupkg
release:
runs-on: ubuntu-latest
needs: publish
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Creating release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Download package
uses: actions/[email protected]
with:
name: PackedLibrary
path: ./Packed
- name: Get exact package name
run: echo "ARTIFACT_FNAME=$(ls ./Packed/*nupkg | grep -Po '(?<=/)[^/]+?$')" >> $GITHUB_ENV
- name: Get package path
run: echo "ARTIFACT_PATH=$(ls ./Packed/*nupkg)" >> $GITHUB_ENV
- name: Add artifact
uses: actions/upload-release-asset@v1

with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.ARTIFACT_PATH }}
asset_name: ${{ env.ARTIFACT_FNAME }}
asset_content_type: application/zip
- name: Pack library
run: dotnet pack -o ./Packed -c Release -p:Deterministic=true
- name: Upload nuget
uses: actions/[email protected]
with:
name: PackedLibrary
path: ./Packed
- name: Publish to github package registry
run: dotnet nuget push -s 'https://nuget.pkg.github.com/Ilia-Kosenkov/index.json' -k $GITHUB_TOKEN --skip-duplicate ./Packed/*nupkg

- name: Creating release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

- name: Get exact package name and path
run: |
echo "ARTIFACT_FNAME=$(ls ./Packed/*nupkg | grep -Po '(?<=/)[^/]+?$')" >> $GITHUB_ENV
echo "ARTIFACT_PATH=$(ls ./Packed/*nupkg)" >> $GITHUB_ENV
- name: Add artifact
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.ARTIFACT_PATH }}
asset_name: ${{ env.ARTIFACT_FNAME }}
asset_content_type: application/zip


0 comments on commit eb07c99

Please sign in to comment.