diff --git a/.github/prepare-library.sh b/.github/prepare-library.sh new file mode 100755 index 0000000..e42cb7a --- /dev/null +++ b/.github/prepare-library.sh @@ -0,0 +1,7 @@ +VERSION=$1 + +xmlstarlet edit \ + --inplace \ + --update "/Project/PropertyGroup/AssemblyVersion" \ + --value "$VERSION" \ + GoDough.csproj \ No newline at end of file diff --git a/.github/release-package.sh b/.github/release-package.sh new file mode 100755 index 0000000..819cd91 --- /dev/null +++ b/.github/release-package.sh @@ -0,0 +1,4 @@ +VERSION=$1 + +dotnet pack --configuration Release +echo dotnet nuget push GoDough.${VERSION}.nupkg \ No newline at end of file diff --git a/.github/workflows/on_push.yml b/.github/workflows/on_push.yml new file mode 100644 index 0000000..5e4922e --- /dev/null +++ b/.github/workflows/on_push.yml @@ -0,0 +1,47 @@ +name: Build & Release +on: push +permissions: + contents: read + packages: read + +jobs: + on_push: + permissions: + contents: write + packages: write + name: On Push + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 20.8.1 + - name: Setup xmlstarlet + run: sudo apt update && apt install -y xmlstarlet + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 6.0.421 + - name: Cache npm + uses: actions/cache@v3 + with: + path: ~/.npm + key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + - name: Build + run: dotnet build --configuration Release + - name: Test + run: dotnet test --configuration Release --no-build + - name: Publish package + run: | + npx \ + --package @semantic-release/commit-analyzer \ + --package @semantic-release/release-notes-generator \ + --package @semantic-release/github \ + --package @semantic-release/exec \ + --package @semantic-release/git \ + semantic-release + if: github.ref_name == 'main' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.releaserc.js b/.releaserc.js new file mode 100644 index 0000000..5a57f2b --- /dev/null +++ b/.releaserc.js @@ -0,0 +1,36 @@ +module.exports = { + branches: ['main'], + plugins: [ + [ + '@semantic-release/commit-analyzer', + { + preset: 'angular', + releaseRules: [ + { type: 'docs', scope: 'README', release: 'patch' }, + { type: 'refactor', release: 'patch' }, + { type: 'style', release: 'patch' }, + ], + parserOpts: { + noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES'], + }, + }, + ], + '@semantic-release/release-notes-generator', + '@semantic-release/github', + [ + '@semantic-release/exec', + { + prepareCmd: './.github/prepare-library.sh ${nextRelease.version}', + publishCmd: './.github/release-package.sh ${nextRelease.version}', + }, + ], + [ + '@semantic-release/git', + { + assets: ['GoDough.csproj'], + message: + 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}', + }, + ], + ], +}; diff --git a/GoDough.csproj b/GoDough.csproj index a18fdf2..025b1d2 100644 --- a/GoDough.csproj +++ b/GoDough.csproj @@ -1,11 +1,12 @@ + net6.0 true + 3.4.5 - - - + +