-
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (88 loc) · 5.25 KB
/
Copy pathupdate_version.yaml
File metadata and controls
102 lines (88 loc) · 5.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# This is a basic workflow to help you get started with Actions
name: "Change version"
# Controls when the action will run. Triggers the workflow on push
# events but only for the master branch
on:
workflow_dispatch:
inputs:
CurrentVersion:
description: 'The current version'
required: true
type: string
PreReleaseCurrentVersion:
description: 'The current version pre-release tag (without dash, e.g. rc)'
required: false
type: string
NewVersion:
description: 'The new version'
required: true
type: string
PreReleaseNewVersion:
description: 'The new version pre-release tag (without dash, e.g. rc)'
required: false
type: string
# This workflow contains one job called "update_version"
jobs:
update_version:
# The type of runner that the job will run on
runs-on: windows-2022
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Support longpaths
- name: Support long paths
run: git config --system core.longpaths true
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v7
with:
fetch-depth: '1'
# Compute pre-release tags with dash (used by nuspec, csproj, props)
# psd1 uses the raw input directly (no dash)
- name: Compute pre-release tags
run: |
$preC = if ('${{ inputs.PreReleaseCurrentVersion }}') { '-${{ inputs.PreReleaseCurrentVersion }}' } else { '' }
$preN = if ('${{ inputs.PreReleaseNewVersion }}') { '-${{ inputs.PreReleaseNewVersion }}' } else { '' }
echo "PRE_C=$preC" >> $env:GITHUB_ENV
echo "PRE_N=$preN" >> $env:GITHUB_ENV
# pom.xml: no pre-release, version only
- run: (Get-Content ${{ github.workspace }}\src\jvm\netpdf\pom.xml).Replace('<netpdfversion>${{ inputs.CurrentVersion }}.0</netpdfversion>', '<netpdfversion>${{ inputs.NewVersion }}.0</netpdfversion>') | Set-Content ${{ github.workspace }}\src\jvm\netpdf\pom.xml
# Common.props: uses dash-prefixed pre-release tag
- run: (Get-Content ${{ github.workspace }}\src\net\Common\Common.props).Replace('<Version>${{ inputs.CurrentVersion }}.0${{ env.PRE_C }}</Version>', '<Version>${{ inputs.NewVersion }}.0${{ env.PRE_N }}</Version>') | Set-Content ${{ github.workspace }}\src\net\Common\Common.props
# nuspec files: uses dash-prefixed pre-release tag
- run: (Get-Content ${{ github.workspace }}\src\net\NetPDFCLI\NetPDFCLI.nuspec).Replace('<version>${{ inputs.CurrentVersion }}${{ env.PRE_C }}</version>', '<version>${{ inputs.NewVersion }}${{ env.PRE_N }}</version>') | Set-Content ${{ github.workspace }}\src\net\NetPDFCLI\NetPDFCLI.nuspec
# psd1 files: ModuleVersion and Prerelease are updated separately
# ModuleVersion accepts only numeric version, Prerelease uses raw input (no dash)
- name: Update MASES.NetPDFPS.psd1
run: |
$f = '${{ github.workspace }}\src\net\NetPDFPS\MASES.NetPDFPS.psd1'
(Get-Content $f).
Replace("ModuleVersion = '${{ inputs.CurrentVersion }}'", "ModuleVersion = '${{ inputs.NewVersion }}'").
Replace("Prerelease = '${{ inputs.PreReleaseCurrentVersion }}'", "Prerelease = '${{ inputs.PreReleaseNewVersion }}'") |
Set-Content $f
- name: Update MASES.NetPDFPSCore.psd1
run: |
$f = '${{ github.workspace }}\src\net\NetPDFPS\MASES.NetPDFPSCore.psd1'
(Get-Content $f).
Replace("ModuleVersion = '${{ inputs.CurrentVersion }}'", "ModuleVersion = '${{ inputs.NewVersion }}'").
Replace("Prerelease = '${{ inputs.PreReleaseCurrentVersion }}'", "Prerelease = '${{ inputs.PreReleaseNewVersion }}'") |
Set-Content $f
- name: Update MASES.NetPDFPSFramework.psd1
run: |
$f = '${{ github.workspace }}\src\net\NetPDFPS\MASES.NetPDFPSFramework.psd1'
(Get-Content $f).
Replace("ModuleVersion = '${{ inputs.CurrentVersion }}'", "ModuleVersion = '${{ inputs.NewVersion }}'").
Replace("Prerelease = '${{ inputs.PreReleaseCurrentVersion }}'", "Prerelease = '${{ inputs.PreReleaseNewVersion }}'") |
Set-Content $f
# csproj templates: uses dash-prefixed pre-release tag
- run: (Get-Content ${{ github.workspace }}\src\net\templates\templates\netpdfApp\netpdfApp.csproj).Replace('${{ inputs.CurrentVersion }}${{ env.PRE_C }}', '${{ inputs.NewVersion }}${{ env.PRE_N }}') | Set-Content ${{ github.workspace }}\src\net\templates\templates\netpdfApp\netpdfApp.csproj
- name: Request a PR to commit changes
uses: peter-evans/create-pull-request@v8
with:
branch-suffix: short-commit-hash
add-paths: src/*.*
commit-message: Update version from ${{ inputs.CurrentVersion }}${{ env.PRE_C }} to ${{ inputs.NewVersion }}${{ env.PRE_N }}
title: Update version from ${{ inputs.CurrentVersion }}${{ env.PRE_C }} to ${{ inputs.NewVersion }}${{ env.PRE_N }}
body: |
Automated changes by GitHub action fix #47
reviewers: masesdevelopers
assignees: masesdevelopers
labels: enhancement, Docker, java, NetPDF, NetPDF CLI, NetPDF PowerShell, NetPDF Template, .NET