Merge pull request #15 from LBHackney-IT/feature/github_actions_secrets #82
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
name: publish-nuget-package | |
on: | |
push: | |
branches: | |
- main | |
- feature/** | |
jobs: | |
calculate-version: | |
name: Calculate Version | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.gitversion.outputs.nuGetVersionV2 }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: '5.x' | |
- name: Determine package version | |
id: gitversion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
useConfigFile: true | |
- name: Display package version | |
run: | | |
echo "Version: $GITVERSION_NUGETVERSIONV2" | |
check-code-formatting: | |
name: Check code formatting | |
runs-on: ubuntu-latest | |
needs: calculate-version | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Install dotnet format | |
run: dotnet tool install dotnet-format --tool-path ./dotnet-format-local/ | |
- name: Run formatter check | |
run: ./dotnet-format-local/dotnet-format --check | |
build-and-test: | |
name: Build & Test | |
runs-on: ubuntu-latest | |
needs: calculate-version | |
env: | |
LBHPACKAGESTOKEN: ${{secrets.GITHUB_TOKEN }} | |
outputs: | |
version: ${{ needs.calculate-version.outputs.version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Build | |
run: docker compose build hackney-shared-activity-history-test | |
- name: Run tests | |
run: docker compose run hackney-shared-activity-history-test | |
publish-package: | |
name: Publish Package | |
runs-on: ubuntu-latest | |
needs: build-and-test | |
env: | |
LBHPACKAGESTOKEN: ${{secrets.GITHUB_TOKEN }} | |
VERSION: ${{ needs.build-and-test.outputs.version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Build the Package | |
run: dotnet pack Hackney.Shared.ActivityHistory -p:PackageVersion=$VERSION --configuration Release | |
- name: Publish the Package | |
run: | | |
cd Hackney.Shared.ActivityHistory/bin/Release | |
dotnet nuget push Hackney.Shared.ActivityHistory.*.nupkg -s https://nuget.pkg.github.com/LBHackney-IT/index.json --api-key ${{ secrets.GITHUB_TOKEN }} |