Skip to content

Commit

Permalink
Fix release triggers; Fix inputs to use env variables; Only publish p…
Browse files Browse the repository at this point in the history
…ackages on releases, both release and pre-release
  • Loading branch information
Psypher9 committed Apr 18, 2023
1 parent 4f61367 commit b818067
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions .github/workflows/basic-repos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,47 @@ on:
release:
types:
- created
workflow_dispatch:

jobs:
Build_Test:
environment: ${{ fromJSON('{"release":"prod","push":"preview"}')[github.event_name] || 'PR' }}
Build_Test:
runs-on: ubuntu-latest
env:
build_version: ${{ fromJSON('{"release":"","push":"-preview"}')[github.event_name] || '-beta' }}
package_name: BasicRepos
project_path: src/BasicRepos.csproj
test_project_path: tests/BasicRepos.Test.csproj
steps:
- name: checkout
uses: actions/[email protected]

- name: Add Package source
run: dotnet nuget add source https://nuget.pkg.github.com/astro-panda/index.json --name github --username "${{ github.repository_owner }}" --password "${{ secrets.GITHUB_TOKEN }}" --store-password-in-clear-text

- name: Restore ${{ inputs.package_name }}
- name: Restore ${{ env.package_name }}
run: |-
dotnet restore ${{ inputs.project_path }}
dotnet restore ${{ env.project_path }}
- name: Build ${{ inputs.package_name }}
- name: Build ${{ env.package_name }}
run: |-
dotnet build --no-restore ${{ inputs.project_path }}
dotnet build --no-restore ${{ env.project_path }}
- name: Test ${{ inputs.package_name }}
if: ${{ inputs.test_project }}
- name: Test ${{ env.package_name }}
if: ${{ env.test_project_path }}
run: |-
dotnet test ${{ inputs.test_project }} --logger trx --results-directory "${{ runner.temp }}"
dotnet test ${{ env.test_project_path }} --logger trx --results-directory "${{ runner.temp }}"
- name: Test ${{ inputs.package_name }}
- name: Test ${{ env.package_name }}
if: always()
uses: NasAmin/[email protected]
with:
TRX_PATH: "${{ runner.temp }}"
REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Pack ${{ inputs.package_name }}
if: (github.ref_name == 'main' && github.event_name == 'push') || github.event_name == 'workflow_dispatch'
run: |-
dotnet pack ${{ inputs.project_path }} --version-suffix $build_version-${{ github.run_number }} --output "${{ runner.temp }}"
- name: Pack ${{ inputs.package_name }} Production
- name: Pack ${{ env.package_name }}
if: github.event_name == 'release'
run: |-
dotnet pack ${{ inputs.project_path }} -p:Version=${{ github.ref_name }} --output "${{ runner.temp }}"
dotnet pack ${{ env.project_path }} -p:Version=${{ github.ref_name }} --output "${{ runner.temp }}"
- name: Publish ${{ inputs.package_name }}
if: (github.ref_name == 'main' && github.event_name == 'push') || github.event_name == 'workflow_dispatch' || github.event_name == 'release'
- name: Publish ${{ env.package_name }}
if: github.event_name == 'release'
run: |-
dotnet nuget push ${{ runner.temp }}/*.nupkg -s github

0 comments on commit b818067

Please sign in to comment.