From 9d3517a7f7057a7d6c95a61dcc3b33142db729e1 Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Fri, 6 Sep 2024 17:41:19 -0300 Subject: [PATCH] Add CI/CD workflow for gh extension --- .github/workflows/build.yml | 102 ---------------------------------- .github/workflows/ci.yml | 74 ++++++++++++++++++++++++ .github/workflows/publish.yml | 57 ------------------- .netconfig | 8 +-- 4 files changed, 76 insertions(+), 165 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 648d55a..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,102 +0,0 @@ -ο»Ώ# Builds and runs tests in all three supported OSes -# Pushes CI feed if secrets.SLEET_CONNECTION is provided - -name: build -on: - workflow_dispatch: - inputs: - configuration: - type: choice - description: Configuration - options: - - Release - - Debug - push: - branches: [ main, dev, 'dev/*', 'feature/*', 'rel/*' ] - paths-ignore: - - changelog.md - - readme.md - pull_request: - types: [opened, synchronize, reopened] - -env: - DOTNET_NOLOGO: true - PackOnBuild: true - GeneratePackageOnBuild: true - VersionPrefix: 42.42.${{ github.run_number }} - VersionLabel: ${{ github.ref }} - GH_TOKEN: ${{ secrets.GH_TOKEN }} - MSBUILDTERMINALLOGGER: auto - Configuration: ${{ github.event.inputs.configuration || 'Release' }} - -defaults: - run: - shell: bash - -jobs: - os-matrix: - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.lookup.outputs.matrix }} - steps: - - name: 🀘 checkout - uses: actions/checkout@v4 - - - name: πŸ”Ž lookup - id: lookup - shell: pwsh - run: | - $path = './.github/workflows/os-matrix.json' - $os = if (test-path $path) { cat $path } else { '["ubuntu-latest"]' } - echo "matrix=$os" >> $env:GITHUB_OUTPUT - - build: - needs: os-matrix - name: build-${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: ${{ fromJSON(needs.os-matrix.outputs.matrix) }} - steps: - - name: 🀘 checkout - uses: actions/checkout@v4 - with: - submodules: recursive - fetch-depth: 0 - - - name: πŸ™ build - run: dotnet build -m:1 -bl:build.binlog - - - name: πŸ§ͺ test - run: | - dotnet tool update -g dotnet-retest - dotnet retest -- --no-build - - - name: πŸ› logs - uses: actions/upload-artifact@v3 - if: runner.debug && always() - with: - name: logs - path: '*.binlog' - - - name: πŸš€ sleet - env: - SLEET_CONNECTION: ${{ secrets.SLEET_CONNECTION }} - if: env.SLEET_CONNECTION != '' - run: | - dotnet tool install -g --version 4.0.18 sleet - sleet push bin --config none -f --verbose -p "SLEET_FEED_CONTAINER=nuget" -p "SLEET_FEED_CONNECTIONSTRING=${{ secrets.SLEET_CONNECTION }}" -p "SLEET_FEED_TYPE=azure" || echo "No packages found" - - dotnet-format: - runs-on: ubuntu-latest - steps: - - name: 🀘 checkout - uses: actions/checkout@v4 - with: - submodules: recursive - fetch-depth: 0 - - - name: βœ“ ensure format - run: | - dotnet format whitespace --verify-no-changes -v:diag --exclude ~/.nuget - dotnet format style --verify-no-changes -v:diag --exclude ~/.nuget diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b1810aa --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,74 @@ +ο»Ώname: ci/cd +on: + pull_request: + workflow_dispatch: + push: + branches: [main] + release: + types: [released] + +env: + RestoreUseSkipNonexistentTargets: true + Configuration: Release + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: 🀘 checkout + uses: actions/checkout@v3 + + - name: πŸ“¦ publish + run: | + dotnet publish src/Extension/Extension.csproj -r win-x64 -o bin/win-x64 + dotnet publish src/Extension/Extension.csproj -r osx-x64 -o bin/osx-x64 + dotnet publish src/Extension/Extension.csproj -r osx-arm64 -o bin/osx-arm64 + dotnet publish src/Extension/Extension.csproj -r linux-x64 -o bin/linux-x64 + + - name: ➑️ artifacts + run: | + mkdir -p ${{ runner.temp }}/staging + cp bin/win-x64/gh-sponsors.exe ${{ runner.temp }}/staging/sponsors-windows-amd64.exe + cp bin/osx-x64/gh-sponsors ${{ runner.temp }}/staging/sponsors-darwin-amd64 + cp bin/osx-arm64/gh-sponsors ${{ runner.temp }}/staging/sponsors-darwin-arm64 + cp bin/linux-x64/gh-sponsors ${{ runner.temp }}/staging/sponsors-linux-amd64 + + - name: ⬆️ upload + uses: actions/upload-artifact@v3 + with: + name: executables + path: ${{ runner.temp }}/staging/* + + publish: + runs-on: windows-latest + continue-on-error: true + needs: build + if: github.event_name == 'release' + defaults: + run: + shell: pwsh + steps: + - name: πŸ€– defaults + uses: devlooped/actions-bot@v1 + with: + name: ${{ secrets.BOT_NAME }} + email: ${{ secrets.BOT_EMAIL }} + gh_token: ${{ secrets.GH_TOKEN }} + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: 🀘 checkout + uses: actions/checkout@v3 + with: + token: ${{ env.GH_TOKEN }} + + - name: ⬇️ artifacts + uses: actions/download-artifact@v3 + with: + name: executables + path: ${{ runner.temp }}/dist + + - name: πŸš€ release + run: | + dotnet tool update -g dotnet-gcm + dotnet gcm store --protocol=https --host=github.com --username=$env:GITHUB_ACTOR --password=$env:GH_TOKEN + gci ${{ runner.temp }}/dist | %{ gh release upload ${{ github.event.release.tag_name }} $_.FullName } diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 516aba4..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,57 +0,0 @@ -ο»Ώ# Builds a final release version and pushes to nuget.org -# whenever a release is published. -# Requires: secrets.NUGET_API_KEY - -name: publish -on: - release: - types: [prereleased, released] - -env: - DOTNET_NOLOGO: true - Configuration: Release - PackOnBuild: true - GeneratePackageOnBuild: true - VersionLabel: ${{ github.ref }} - GH_TOKEN: ${{ secrets.GH_TOKEN }} - MSBUILDTERMINALLOGGER: auto - -jobs: - publish: - runs-on: ${{ vars.PUBLISH_AGENT || 'ubuntu-latest' }} - steps: - - name: 🀘 checkout - uses: actions/checkout@v4 - with: - submodules: recursive - fetch-depth: 0 - - - name: πŸ™ build - run: dotnet build -m:1 -bl:build.binlog - - - name: πŸ§ͺ test - run: | - dotnet tool update -g dotnet-retest - dotnet retest -- --no-build - - - name: πŸ› logs - uses: actions/upload-artifact@v3 - if: runner.debug && always() - with: - name: logs - path: '*.binlog' - - - name: πŸš€ nuget - env: - NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} - if: ${{ env.NUGET_API_KEY != '' && github.event.action != 'prereleased' }} - working-directory: bin - run: dotnet nuget push *.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}} --skip-duplicate - - - name: πŸš€ sleet - env: - SLEET_CONNECTION: ${{ secrets.SLEET_CONNECTION }} - if: env.SLEET_CONNECTION != '' - run: | - dotnet tool install -g --version 4.0.18 sleet - sleet push bin --config none -f --verbose -p "SLEET_FEED_CONTAINER=nuget" -p "SLEET_FEED_CONNECTIONSTRING=${{ secrets.SLEET_CONNECTION }}" -p "SLEET_FEED_TYPE=azure" || echo "No packages found" diff --git a/.netconfig b/.netconfig index fab5c31..998f5a0 100644 --- a/.netconfig +++ b/.netconfig @@ -34,9 +34,7 @@ weak [file ".github/workflows/build.yml"] url = https://github.com/devlooped/oss/blob/main/.github/workflows/build.yml - sha = 7ec91019eddb4fc7e0b09118538b256087f82e18 - etag = 35b2a5b03c26cbe7522e30b2b987e04991e8ba18accd38b7ebd88191f1698c2d - weak + skip [file ".github/workflows/changelog.config"] url = https://github.com/devlooped/oss/blob/main/.github/workflows/changelog.config sha = 08d83cb510732f861416760d37702f9f55bd7f9e @@ -59,9 +57,7 @@ weak [file ".github/workflows/publish.yml"] url = https://github.com/devlooped/oss/blob/main/.github/workflows/publish.yml - sha = fcfc66a8735f5338f97c7292db5f4ee83a712254 - etag = e3269a4ec0a33deccb7e35b51178aa34831146a709af435fd10e659cd4dd967b - weak + skip [file ".github/workflows/triage.yml"] url = https://github.com/devlooped/oss/blob/main/.github/workflows/triage.yml sha = 33000c0c4ab4eb4e0e142fa54515b811a189d55c