diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml deleted file mode 100644 index f0f8db774..000000000 --- a/.github/workflows/build-release.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: Component Detection CI - -on: - push: - branches: - - main - release: - types: - - published - -jobs: - build: - - runs-on: ubuntu-latest - - env: - OFFICIAL_BUILD: 'True' - # Set the build number in MinVer. - MINVERBUILDMETADATA: build.${{github.run_number}} - - steps: - - uses: actions/checkout@v2.3.2 - with: - fetch-depth: 0 - - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1.x - - - name: dotnet restore - run: dotnet restore - - - name: Build and publish - run: dotnet publish -o dist --no-self-contained -c Release ./src/Microsoft.ComponentDetection - - - name: Create temporary folder for release - run: mkdir ./dist-release - - - name: Tar the output - run: tar -C ./dist -cvf ./dist-release/component-detection.tar.gz . - - - name: Get release - if: github.event_name == 'release' - id: get_release - uses: bruceadams/get-release@v1.2.3 - env: - GITHUB_TOKEN: ${{ github.token }} - - - name: Upload Extension Release Asset - id: upload-component-detection-release-asset - if: github.event_name == 'release' - uses: actions/upload-release-asset@v1.0.2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.get_release.outputs.upload_url }} - asset_path: ./dist-release/component-detection.tar.gz - asset_name: component-detection.tar.gz - asset_content_type: application/zip - - - name: Add NuGet publication source for Github packages - if: github.event_name == 'release' - run: dotnet nuget add source https://nuget.pkg.github.com/microsoft/index.json --password $GITHUB_TOKEN --username notused --store-password-in-clear-text --name cgwriter - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Add NuGet publication source for Azure Artifacts Packaging feed - if: github.event_name == 'release' - run: dotnet nuget add source https://1essharedassets.pkgs.visualstudio.com/1esPkgs/_packaging/ComponentDetection/nuget/v3/index.json --password $AZART_TOKEN --username az --store-password-in-clear-text --name Packaging - env: - AZART_TOKEN: ${{ secrets.AZART_TOKEN }} - - - name: Generate NuGet packages - if: github.event_name == 'release' - run: dotnet pack -o dist-nuget -c Release - - # dotnet nuget push seems to have some probs, use curl for GH - - name: Publish nuget - if: github.event_name == 'release' - run: | - for f in ./dist-nuget/*.nupkg - do - curl -vX PUT -u "[user]:${{ secrets.GITHUB_TOKEN }}" -F package=@$f https://nuget.pkg.github.com/microsoft/ - dotnet nuget push --source "Packaging" --api-key az $f - done - shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 037676678..a6e2c165b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,10 +1,14 @@ -name: Component Detection PR +name: Build -on: [pull_request] +on: + push: + pull_request: + +permissions: + contents: read jobs: build: - runs-on: ubuntu-latest env: @@ -13,20 +17,21 @@ jobs: MINVERBUILDMETADATA: build.${{github.run_number}} steps: - - uses: actions/checkout@v2.3.2 - with: - fetch-depth: 0 + - name: Checkout repository + uses: actions/checkout@v2.3.2 + with: + fetch-depth: 0 - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1.x + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.x - - name: dotnet restore - run: dotnet restore + - name: Restore packages + run: dotnet restore - - name: Build and publish - run: dotnet publish -o dist --no-self-contained -c Release ./src/Microsoft.ComponentDetection + - name: Build + run: dotnet build --no-restore --configuration Debug - - name: Run tests - run: dotnet test + - name: Run tests + run: dotnet test --no-build --configuration Debug diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..b77396279 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,55 @@ +name: Release + +on: + release: + types: + - published + +permissions: + contents: write + packages: write + +jobs: + release: + runs-on: ubuntu-latest + strategy: + matrix: + rid: [win-x64, linux-x64, osx-x64] + + env: + OFFICIAL_BUILD: 'True' + # Set the build number in MinVer. + MINVERBUILDMETADATA: build.${{github.run_number}} + + steps: + - name: Checkout repository + uses: actions/checkout@v2.4.0 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v1.9.0 + with: + dotnet-version: 3.1.x + + - name: Restore packages + run: dotnet restore + + - name: Build CLI tool + run: dotnet publish --configuration Release --output ./bin --self-contained --runtime ${{ matrix.rid }} -p:PublishSingleFile=true -p:DebugType=None -p:PublishTrimmed=true ./src/Microsoft.ComponentDetection + + - name: Publish CLI tool + uses: shogo82148/actions-upload-release-asset@v1.4.0 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./bin/* + asset_name: component-detection-${{ matrix.rid }}${{ matrix.rid == 'win-x64' && '.exe' || '' }} + + - name: Build NuGet packages + run: dotnet pack --configuration Release --output ./out + + - name: Publish NuGet packages to GitHub Packages + run: dotnet nuget push ./out/*.nupkg --skip-duplicate --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/${{ github.repository_owner }} + + - name: Publish NuGet packages to Azure Artifacts + run: dotnet nuget push ./out/*.nupkg --skip-duplicate --api-key ${{ secrets.AZART_TOKEN }} --source https://1essharedassets.pkgs.visualstudio.com/1esPkgs/_packaging/ComponentDetection/nuget/v3/index.json