From ff3f2ff05503cc6f05fc8802505c70eeb3d55348 Mon Sep 17 00:00:00 2001 From: lemccomb <117306942+lemccomb@users.noreply.github.com> Date: Tue, 26 Sep 2023 17:39:26 -0700 Subject: [PATCH 1/3] Add workflow for manually created releases --- .github/workflows/ManuaRelease.yml | 27 ++++++++++++++ .github/workflows/UploadAssets.yml | 58 ++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 .github/workflows/ManuaRelease.yml create mode 100644 .github/workflows/UploadAssets.yml diff --git a/.github/workflows/ManuaRelease.yml b/.github/workflows/ManuaRelease.yml new file mode 100644 index 00000000..2a12d9fb --- /dev/null +++ b/.github/workflows/ManuaRelease.yml @@ -0,0 +1,27 @@ +name: Manual Release +on: + release: + types: [published] + +jobs: + get_release_type: + runs-on: ubuntu-latest + outputs: + release_type: ${{ steps.get_release_type.outputs.release_type }} + steps: + - uses: actions/checkout@v2 + - name: Get Release Type + id: get_release_type + run: | + if [[ ${{ github.event.release.prerelease }} == true ]]; then + echo "This is an automated release. Skipping..." + echo "::set-output name=is_official_release::false" + else + echo "This is an official release. Uploading assets..." + echo "::set-output name=is_official_release::true" + fi + + # Upload the release artifacts but only if it's an official release + - name: Call Upload Assets action + if: steps.get_release_type.outputs.is_official_release + uses: ./.github/workflows/UploadAssets.yml diff --git a/.github/workflows/UploadAssets.yml b/.github/workflows/UploadAssets.yml new file mode 100644 index 00000000..b8cd27bf --- /dev/null +++ b/.github/workflows/UploadAssets.yml @@ -0,0 +1,58 @@ +name: Upload Assets +on: + workflow_call: + +jobs: + # Publish and zip the binaries and upload them to the release. + release_assets: + name: release-assets + if: ${{ github.event_name != 'pull_request' }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: windows-latest + dir_command: gci -Recurse + zip_command_debug: Compress-Archive -Path ./debug/ -DestinationPath CoseSignTool-Windows-debug.zip + zip_command_release: Compress-Archive -Path ./release/ -DestinationPath CoseSignTool-Windows-release.zip + - os: ubuntu-latest + dir_command: ls -a -R + zip_command_debug: zip -r CoseSignTool-Linux-debug.zip ./debug/ + zip_command_release: zip -r CoseSignTool-Linux-release.zip ./release/ + - os: macos-latest + dir_command: ls -a -R + zip_command_debug: zip -r CoseSignTool-MacOS-debug.zip ./debug/ + zip_command_release: zip -r CoseSignTool-MacOS-release.zip ./release/ + + steps: + # Checkout the branch. + - name: Checkout code again + uses: actions/checkout@v3 + + # Build and publish the binaries to ./published. + # Note: We have to use the solution files to get the right output paths, due to the mix of .NET 7 and .NET Standard projects. + - name: Publish outputs + run: | + dotnet publish --configuration Debug --output published/debug CoseSignTool/CoseSignTool.sln + dotnet publish --configuration Release --output published/release CoseSignTool/CoseSignTool.sln + + # Create zip files for release. + - name: Create zip files for the release + run: | + ${{ matrix.zip_command_debug }} + ${{ matrix.zip_command_release }} + working-directory: ./published + + # List the contents of the published directory to make sure all the artifacts are there. + - name: List published directory + run: ${{ matrix.dir_command }} + working-directory: ./published + + # Upload the zipped assets to the release. + - name: Upload artifacts + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./published/CoseSignTool-*.zip + file_glob: true + overwrite: true \ No newline at end of file From 8977cab4be2b42a91afff74d7f34941af939b2a6 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 27 Sep 2023 00:41:08 +0000 Subject: [PATCH 2/3] Update changelog for release --- CHANGELOG.md | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41a92346..94ccfb9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,37 +1,18 @@ # Changelog -## [v0.0.2-pre.1](https://github.com/microsoft/CoseSignTool/tree/v0.0.2-pre.1) (2023-09-26) +## [Unreleased](https://github.com/microsoft/CoseSignTool/tree/HEAD) -[Full Changelog](https://github.com/microsoft/CoseSignTool/compare/v0.0.2...v0.0.2-pre.1) +[Full Changelog](https://github.com/microsoft/CoseSignTool/compare/v0.3.1...HEAD) **Merged pull requests:** +- Test publish [\#26](https://github.com/microsoft/CoseSignTool/pull/26) ([lemccomb](https://github.com/lemccomb)) +- Enable official releases [\#25](https://github.com/microsoft/CoseSignTool/pull/25) ([lemccomb](https://github.com/lemccomb)) - checkout from main instead of current branch to get semver [\#24](https://github.com/microsoft/CoseSignTool/pull/24) ([lemccomb](https://github.com/lemccomb)) - -## [v0.0.2](https://github.com/microsoft/CoseSignTool/tree/v0.0.2) (2023-09-26) - -[Full Changelog](https://github.com/microsoft/CoseSignTool/compare/v0.0.1...v0.0.2) - -**Merged pull requests:** - - Update dotnet.yml with missing pipe [\#23](https://github.com/microsoft/CoseSignTool/pull/23) ([lemccomb](https://github.com/lemccomb)) - Test semver creation via git commands [\#22](https://github.com/microsoft/CoseSignTool/pull/22) ([lemccomb](https://github.com/lemccomb)) - -## [v0.0.1](https://github.com/microsoft/CoseSignTool/tree/v0.0.1) (2023-09-25) - -[Full Changelog](https://github.com/microsoft/CoseSignTool/compare/v0.0.0-pre.1...v0.0.1) - -**Merged pull requests:** - - Attempt to get semver step working again [\#21](https://github.com/microsoft/CoseSignTool/pull/21) ([lemccomb](https://github.com/lemccomb)) - move create\_changelog to before build [\#20](https://github.com/microsoft/CoseSignTool/pull/20) ([lemccomb](https://github.com/lemccomb)) - -## [v0.0.0-pre.1](https://github.com/microsoft/CoseSignTool/tree/v0.0.0-pre.1) (2023-09-08) - -[Full Changelog](https://github.com/microsoft/CoseSignTool/compare/v0.3.1...v0.0.0-pre.1) - -**Merged pull requests:** - - Try release [\#19](https://github.com/microsoft/CoseSignTool/pull/19) ([lemccomb](https://github.com/lemccomb)) - try release [\#18](https://github.com/microsoft/CoseSignTool/pull/18) ([lemccomb](https://github.com/lemccomb)) - Add license text to code files [\#17](https://github.com/microsoft/CoseSignTool/pull/17) ([lemccomb](https://github.com/lemccomb)) From 2b25ba1b2a986e326570f13feca91bcf9b12302c Mon Sep 17 00:00:00 2001 From: lemccomb <117306942+lemccomb@users.noreply.github.com> Date: Tue, 26 Sep 2023 17:44:06 -0700 Subject: [PATCH 3/3] Update dotnet.yml --- .github/workflows/dotnet.yml | 115 +++++++++-------------------------- 1 file changed, 29 insertions(+), 86 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 83abd8e5..2fbce764 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -10,8 +10,6 @@ name: Build, Test, and Publish on: push: branches: [ "main" ] # Trigger on pushes to the main branch. - tags: - - '!*pre*' # Trigger on the creation of non-prerelease tags. pull_request: branches: [ "*" ] # Trigger on all branches for pull requests. @@ -86,7 +84,7 @@ jobs: with: dotnet-version: 7.0.x - # Use the Dotnet Test command to load dependencies, build, and test the code. + # Load the dependencies, build, and test the code. - name: Build and Test debug run: dotnet test --verbosity normal CoseSignTool/CoseSignTool.sln @@ -98,7 +96,6 @@ jobs: # Create a semantically versioned release. # A prerelease is created for every push to the main branch. - # An official release is created when a tag is created manually on GitHub. create_release: name: Create Release if: ${{ github.event_name == 'push' }} @@ -108,16 +105,16 @@ jobs: steps: - name: Checkout code # TODO: See if I can configure this step, or v3, to replace the Fetch and checkout step below. uses: actions/checkout@v3 - with: - ref: main + # with: + # ref: main - # # Checkout the main branch so we can see the correct tag set. - # - name: Fetch and checkout main - # run: | - # git config --local user.email "action@github.com" - # git config --local user.name "GitHub Action" - # git fetch - # git checkout main + # Checkout the main branch so we can see the correct tag set. + - name: Fetch and checkout main + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git fetch + git checkout main # Create a semantically versioned tag that increments the last release. - name: Create SemVer tag @@ -127,19 +124,19 @@ jobs: main_branch_name: "main" debug: true - # Set the tag name and release type, based on whether the workflow was triggered by a tag or by a push to Main. - - name: Choose tag and release type - id: choose-tag - run: | - if [[ ${{ github.ref }} == refs/tags/* ]]; then - echo "This is an official release. Setting tag to ${{ github.ref }}." - echo "::set-output name=TAG_NAME::${{ github.ref }}" - echo "::set-output name=is_prerelease::false" - else - echo "This is an automated release. Setting tag to ${{ steps.semver-tag.outputs.semver_tag }}." - echo "::set-output name=TAG_NAME::${{ steps.semver-tag.outputs.semver_tag }}" - echo "::set-output name=is_prerelease::true" - fi + # # Set the tag name and release type, based on whether the workflow was triggered by a tag or by a push to Main. + # - name: Choose tag and release type + # id: choose-tag + # run: | + # if [[ ${{ github.ref }} == refs/tags/* ]]; then + # echo "This is an official release. Setting tag to ${{ github.ref }}." + # echo "::set-output name=TAG_NAME::${{ github.ref }}" + # echo "::set-output name=is_prerelease::false" + # else + # echo "This is an automated release. Setting tag to ${{ steps.semver-tag.outputs.semver_tag }}." + # echo "::set-output name=TAG_NAME::${{ steps.semver-tag.outputs.semver_tag }}" + # echo "::set-output name=is_prerelease::true" + # fi # Create the release. - name: Create Release @@ -149,69 +146,15 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: # Get the tag name and release name from the previous step. - tag_name: ${{ steps.choose-tag.outputs.TAG_NAME }} - release_name: Release ${{ steps.choose-tag.outputs.TAG_NAME }} + tag_name: ${{ steps.semver-tag.outputs.semver_tag }} + release_name: Release ${{ steps.semver-tag.outputs.semver_tag }} # Generate release text from changelog. body_path: ./CHANGELOG.md # Always use prerelease for automated releases. Official releases are created manually. - prerelease: ${{ steps.choose-tag.outputs.is_prerelease }} - - - # Publish and zip the binaries and upload them to the release. - release_assets: - name: release-assets - needs: [ build, create_release ] - if: ${{ github.event_name != 'pull_request' }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - - os: windows-latest - dir_command: gci -Recurse - zip_command_debug: Compress-Archive -Path ./debug/ -DestinationPath CoseSignTool-Windows-debug.zip - zip_command_release: Compress-Archive -Path ./release/ -DestinationPath CoseSignTool-Windows-release.zip - - os: ubuntu-latest - dir_command: ls -a -R - zip_command_debug: zip -r CoseSignTool-Linux-debug.zip ./debug/ - zip_command_release: zip -r CoseSignTool-Linux-release.zip ./release/ - - os: macos-latest - dir_command: ls -a -R - zip_command_debug: zip -r CoseSignTool-MacOS-debug.zip ./debug/ - zip_command_release: zip -r CoseSignTool-MacOS-release.zip ./release/ - - steps: - # Checkout the branch. - - name: Checkout code again - uses: actions/checkout@v3 - - # Build and publish the binaries to ./published. - # Note: We have to use the solution files to get the right output paths, due to the mix of .NET 7 and .NET Standard projects. - - name: Publish outputs - run: | - dotnet publish --configuration Debug --output published/debug CoseSignTool/CoseSignTool.sln - dotnet publish --configuration Release --output published/release CoseSignTool/CoseSignTool.sln + prerelease: true - # TODO: See if I can get these to run with --no-build. - - # Create zip files for release. - - name: Create zip files for the release - run: | - ${{ matrix.zip_command_debug }} - ${{ matrix.zip_command_release }} - working-directory: ./published - - # List the contents of the published directory to make sure all the artifacts are there. - - name: List published directory - run: ${{ matrix.dir_command }} - working-directory: ./published - - # Upload the zipped assets to the release. - - name: Upload artifacts - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ./published/CoseSignTool-*.zip - file_glob: true - overwrite: true \ No newline at end of file + # Upload the release artifacts. + - name: Call Upload Assets action + uses: ./.github/workflows/UploadAssets.yml