Fix branch name PR code injection vulnerability. #64
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 | |
on: | |
push: | |
branches: [master] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout all commits, so we get previous tags | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
# This is needed so that we can create git tags | |
- name: Set git user | |
run: | | |
git config --local user.name "ci-bot" | |
git config --local user.email "github@clave.no" | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: '16.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Get version | |
id: version | |
run: echo "version=$(npx -q git-conventional-commits version)" >> $GITHUB_OUTPUT | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: 6.0.x | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
env: | |
VERSION: ${{ steps.version.outputs.version }} | |
run: dotnet build --no-restore --configuration release -p:Version=${{ env.VERSION }} | |
- name: Test | |
run: dotnet test --no-build --configuration release --logger "trx;LogFileName=test-results.trx" | |
- name: Report test results | |
uses: dorny/test-reporter@v1 | |
if: success() || failure() # run this step even if previous step failed | |
with: | |
name: Tests | |
path: '**/test-results.trx' | |
reporter: dotnet-trx | |
fail-on-error: 'false' | |
- name: Changelog | |
run: npx -q git-conventional-commits changelog --file CHANGELOG.md | |
- name: Pack | |
env: | |
VERSION: ${{ steps.version.outputs.version }} | |
run: dotnet pack --no-build --include-symbols --configuration release -p:PackageVersion=${{ env.VERSION }} --output ./nugets | |
- name: Push | |
run: dotnet nuget push "**/*.nupkg" --api-key ${{ secrets.NUGET }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
- name: Tag | |
env: | |
VERSION: ${{ steps.version.outputs.version }} | |
run: | | |
git commit -am "Created release v${{ env.VERSION }}" | |
git tag "v${{ env.VERSION }}" | |
git push origin "v${{ env.VERSION }}" | |
git push origin |