Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move upload_assets to happen on release #29

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions .github/workflows/ManualRelease.yml

This file was deleted.

58 changes: 0 additions & 58 deletions .github/workflows/UploadAssets.yml

This file was deleted.

92 changes: 70 additions & 22 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ on:
branches: [ "main" ] # Trigger on pushes to the main branch.
pull_request:
branches: [ "*" ] # Trigger on all branches for pull requests.
release:
types: [ created ] # Trigger on new releases.

jobs:
# If this is a pull request, create a changelog that includes all the PRs merged since the last release.
# Otherwise, skip to the build job.

#### PULL REQUEST EVENTS ####

# Create a changelog that includes all the PRs merged since the last release.
# If it's not a pull request, skip to the build job.
create_changelog:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -61,6 +66,8 @@ jobs:
if: ${{ github.event_name != 'pull_request' }}
run: echo "Changelog is already up to date."

#### SHARED PULL REQUEST AND PUSH EVENTS ####

# Build and test the code.
build:
name: build-${{matrix.os}}
Expand All @@ -84,18 +91,19 @@ jobs:
with:
dotnet-version: 7.0.x

# Load the dependencies, build, and test the code.
# Use the Dotnet Test command to load dependencies, build, and test the code.
- name: Build and Test debug
run: dotnet test --verbosity normal CoseSignTool/CoseSignTool.sln

# List the contents of the working directory to make sure all the artifacts are there.
- name: List working directory
run: ${{ matrix.dir_command }}

######## If this is a pull request build, we're done. ########
#### PUSH EVENTS ####

# Create a semantically versioned release.
# A prerelease is created for every push to the main branch.
# Official releases are created manually on GitHub.
create_release:
name: Create Release
if: ${{ github.event_name == 'push' }}
Expand Down Expand Up @@ -124,21 +132,7 @@ 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

# Create the release.
# Create the release. This should generate a release event, which will trigger the release_assets job.
- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand All @@ -155,6 +149,60 @@ jobs:
# Always use prerelease for automated releases. Official releases are created manually.
prerelease: true

# Upload the release artifacts.
- name: Call Upload Assets action
uses: ./.github/workflows/UploadAssets.yml@main
#### RELEASE EVENTS ####

# Publish and zip the binaries and upload them to the release.
release_assets:
name: release-assets
if: ${{ github.event_name == 'release' }}
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

# 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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [v0.3.1-pre.2](https://github.com/microsoft/CoseSignTool/tree/v0.3.1-pre.2) (2023-09-27)

[Full Changelog](https://github.com/microsoft/CoseSignTool/compare/v0.3.1-pre.1...v0.3.1-pre.2)

**Merged pull requests:**

- adjust fiel paths [\#28](https://github.com/microsoft/CoseSignTool/pull/28) ([lemccomb](https://github.com/lemccomb))

## [v0.3.1-pre.1](https://github.com/microsoft/CoseSignTool/tree/v0.3.1-pre.1) (2023-09-27)

[Full Changelog](https://github.com/microsoft/CoseSignTool/compare/v0.3.1...v0.3.1-pre.1)
Expand Down