-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d0bbace
Showing
13 changed files
with
3,176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 vers-one | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
# .NET project version updater | ||
|
||
A GitHub action to update or bump project versions in .csproj, .cs, and .nuspec files. | ||
|
||
Supports: | ||
|
||
* .NET / .NET Core projects (`.csproj` files); | ||
* .NET Framework AssemblyInfo files (`AssemblyInfo.cs`); | ||
* Nuget package specs (`.nuspec` files). | ||
|
||
## Inputs | ||
|
||
### `file` (required) | ||
|
||
The path to the project file. | ||
|
||
**Example**: `src/MyProject.csproj` | ||
|
||
### `version` (required) | ||
|
||
The new version for the project file. | ||
|
||
Can be either explicit (e.g. `1.2.3` or `1.0.0-beta5`) or one of the bump commands: | ||
|
||
* `bump-major`; | ||
* `bump-minor`; | ||
* `bump-build`; | ||
* `bump-revision`. | ||
|
||
## Outputs | ||
|
||
### `oldVersion` | ||
|
||
The version found in the file before the update. | ||
|
||
**Example**: `1.3.5` | ||
|
||
### `newVersion` | ||
|
||
The version set by the action during the update. | ||
|
||
**Example**: `1.3.6` | ||
|
||
## Usage | ||
|
||
### Scenario 1: Set an explicit version for a single file | ||
|
||
```yaml | ||
name: Manual version update | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "New version for the project" | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
name: Update version | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set MyProject.csproj version | ||
id: update | ||
uses: vers-one/[email protected] | ||
with: | ||
file: "src/MyProject.csproj" | ||
version: ${{ github.event.inputs.version }} | ||
|
||
- run: | | ||
git config user.name "Your Name" | ||
git config user.email "[email protected]" | ||
git add . | ||
git commit -m "Update project version to ${{ steps.update.outputs.newVersion }}" | ||
git push | ||
``` | ||
### Scenario 2: Set an explicit version for multiple files | ||
```yaml | ||
name: Manual version update | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "New version for all projects" | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
name: Update versions | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set MyProject.csproj version | ||
id: update | ||
uses: vers-one/[email protected] | ||
with: | ||
file: "src/MyProject.csproj" | ||
version: ${{ github.event.inputs.version }} | ||
|
||
- name: Set AssemblyInfo.cs version | ||
uses: vers-one/[email protected] | ||
with: | ||
file: "src/Properties/AssemblyInfo.cs" | ||
version: ${{ github.event.inputs.version }} | ||
|
||
- name: Set MyProject.nuspec version | ||
uses: vers-one/[email protected] | ||
with: | ||
file: "src/MyProject.nuspec" | ||
version: ${{ github.event.inputs.version }} | ||
|
||
- run: | | ||
git config user.name "Your Name" | ||
git config user.email "[email protected]" | ||
git add . | ||
git commit -m "Update project versions to ${{ steps.update.outputs.newVersion }}" | ||
git push | ||
``` | ||
### Scenario 3: Bump version | ||
```yaml | ||
name: Bump build version | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
name: Build and bump version | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install .NET 6 | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 6.0.x | ||
|
||
- name: Restore dependencies | ||
run: dotnet restore | ||
|
||
- name: Build | ||
run: dotnet build | ||
|
||
- name: Bump build version | ||
id: bump | ||
uses: vers-one/[email protected] | ||
with: | ||
file: "src/MyProject.csproj" | ||
version: bump-build | ||
|
||
- run: | | ||
git config user.name "Your Name" | ||
git config user.email "[email protected]" | ||
git add . | ||
git commit -m "Bump project version to ${{ steps.bump.outputs.newVersion }}" | ||
git push | ||
``` | ||
## A few notes on version numbers | ||
* This action searches for the following version declarations: | ||
* for .csproj and .nuspec files: `<Version>...</Version>` (case insensitive); | ||
* for .cs files: `[assembly: AssemblyVersion("...")]` and `[assembly: AssemblyFileVersion("...")]`. | ||
* If you set the new version explicitly, you can use any string as a version number (e.g. `1.2.3`, `1.0.0-beta5`, `Vista`, `blah-blah`, etc). However if you use one of the bump commands, the existing version must by in the following format: *major[.minor[.build[.revision]]]*. | ||
* Bump commands don't change any version parts other than requested. For example if you run `bump-minor` command for version `1.5.17`, the new version will be `1.6.17`. Any non-existent version parts will be treated as 0: `bump-revision` on `3.0` will produce `3.0.0.1`. | ||
* Keep in mind that .NET Framework assembly versions [must be](https://docs.microsoft.com/en-us/dotnet/api/system.version#remarks) in the following format: *major.minor[.build[.revision]]*. Any other versions formats like `1.0.0-beta5` will cause a compilation failure. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: ".NET project version updater" | ||
description: "Update or bump project versions in .csproj, .cs, and .nuspec files" | ||
author: "vers-one" | ||
branding: | ||
icon: "rotate-cw" | ||
color: "blue" | ||
inputs: | ||
file: | ||
description: "Project file path" | ||
required: true | ||
version: | ||
description: "New version" | ||
required: true | ||
outputs: | ||
oldVersion: | ||
description: "Version found in the file before the update" | ||
newVersion: | ||
description: "Version set by the action during the update" | ||
runs: | ||
using: "node16" | ||
main: "dist/index.js" |
Oops, something went wrong.