Skip to content

Commit c9de1b4

Browse files
authored
Merge pull request #322 from microsoftgraph/rsh/releaseWorkflow
Create git-release.yml
2 parents e1172e4 + ae15d68 commit c9de1b4

File tree

5 files changed

+74
-42
lines changed

5 files changed

+74
-42
lines changed

.github/workflows/build-and-publish.yml

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3-
4-
name: Build and Publish
1+
name: Build and Publish
52

63
on:
74
push:
@@ -34,13 +31,15 @@ jobs:
3431
with:
3532
java-version: '16'
3633
distribution: 'adopt'
37-
cache: gradle
38-
- run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH
34+
cache: gradle
35+
- name: Download file
36+
run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH
3937
shell: pwsh
4038
env:
4139
ENCODED_VALUE: ${{ secrets.LOCAL_PROPERTIES }}
4240
OUTPUT_PATH: '.\local.properties'
43-
- run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH
41+
- name: Download file
42+
run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH
4443
shell: pwsh
4544
env:
4645
ENCODED_VALUE: ${{ secrets.SECRING_GPG }}
@@ -64,13 +63,15 @@ jobs:
6463
with:
6564
java-version: '16'
6665
distribution: 'adopt'
67-
cache: gradle
68-
- run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH
66+
cache: gradle
67+
- name: Download file
68+
run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH
6969
shell: pwsh
7070
env:
7171
ENCODED_VALUE: ${{ secrets.LOCAL_PROPERTIES }}
72-
OUTPUT_PATH: '.\local.properties'
73-
- run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH
72+
OUTPUT_PATH: '.\local.properties'
73+
- name: Download file
74+
run: .\scripts\decodeAndWrite.ps1 -encodedValue $env:ENCODED_VALUE -outputPath $env:OUTPUT_PATH
7475
shell: pwsh
7576
env:
7677
ENCODED_VALUE: ${{ secrets.SECRING_GPG }}
@@ -95,24 +96,26 @@ jobs:
9596
**/gradle/**
9697
Scripts/**
9798
98-
githubRelease:
99+
create_Tag:
99100
needs: maven_Release
100101
runs-on: ubuntu-latest
102+
env:
103+
RELEASE_TAG: ""
101104
steps:
102105
- uses: actions/checkout@v2
103-
- name: Download Build Artifact
104-
uses: actions/[email protected]
105-
with:
106-
name: drop
107-
path: drop
108-
- name: Github Release
109-
uses: anton-yurchenko/[email protected]
110-
env:
111-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
112-
DRAFT_RELEASE: "false"
113-
PRE_RELEASE: "false"
114-
CHANGELOG_FILE: "CHANGELOG.md"
115-
ALLOW_EMPTY_CHANGELOG: "true"
106+
- name: Get Version
107+
id: GetVersion
108+
run: .\scripts\getLatestVersion.ps1
109+
shell: pwsh
110+
- name: Create tag
111+
uses: rickstaa/[email protected]
112+
with:
113+
tag: ${{ steps.GetVersion.outputs.tag }}
114+
- name: Queue Git Release
115+
uses: benc-uk/workflow-dispatch@v1
116116
with:
117-
args: |
118-
drop/**
117+
workflow: Git Release
118+
token: ${{ secrets.PERSONAL_TOKEN }}
119+
ref: ${{ steps.GetVersion.outputs.tag }}
120+
121+

.github/workflows/git-release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Git Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
workflow_dispatch:
8+
9+
jobs:
10+
Git_Release:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Download Build Artifact
15+
uses: dawidd6/[email protected]
16+
with:
17+
workflow: build-and-publish.yml
18+
workflow_conclusion: success
19+
branch: master
20+
event: push
21+
name: drop
22+
- name: Github Release
23+
uses: anton-yurchenko/[email protected]
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
26+
DRAFT_RELEASE: "false"
27+
PRE_RELEASE: "false"
28+
CHANGELOG_FILE: "CHANGELOG.md"
29+
ALLOW_EMPTY_CHANGELOG: "true"
30+
with:
31+
args: |
32+
drop/**

.github/workflows/gradle-build.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3-
41
name: Java CI with Gradle
52

63
on:
@@ -48,7 +45,4 @@ jobs:
4845
settings.gradle
4946
gradle.properties
5047
**/gradle/**
51-
Scripts/**
52-
53-
54-
48+
Scripts/**
File renamed without changes.

scripts/getLatestVersion.ps1

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,17 @@ if($propertiesPath -eq "" -or $null -eq $propertiesPath) {
2121
}
2222
$file = get-item $propertiesPath
2323
$findVersions = $file | Select-String -Pattern "mavenMajorVersion" -Context 0,2
24-
$findVersions = $findVersions -split "`r`n"
24+
$content = Get-Content $propertiesPath
2525

26-
$versionIndex = $findVersions[0].IndexOf("=")
27-
$majorVersion = $findVersions[0].Substring($versionIndex+2)
28-
$minorVersion = $findVersions[1].Substring($versionIndex+2)
29-
$patchVersion = $findVersions[2].Substring($versionIndex+2)
26+
$lineNumber = $findVersions.LineNumber - 1
27+
$versionIndex = $content[$lineNumber].IndexOf("=")
28+
$versionIndex += 2 # skipping =[space]
29+
$majorVersion = $content[$lineNumber].Substring($versionIndex)
30+
$lineNumber++
31+
$minorVersion = $content[$lineNumber].Substring($versionIndex)
32+
$lineNumber++
33+
$patchVersion = $content[$lineNumber].Substring($versionIndex)
3034
$version = "$majorVersion.$minorVersion.$patchVersion"
3135

32-
#Update the VERSION_STRING env variable and inform the user
33-
Write-Host "##vso[task.setVariable variable=VERSION_STRING]$($version)";
34-
Write-Host "Updated the VERSION_STRING enviornment variable with the current Gradle.Properties, $version"
36+
#Set Task output to create tag
37+
Write-Output "::set-output name=tag::v${version}"

0 commit comments

Comments
 (0)