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

OSOE-735: Introduce versioning and releases #325

Merged
merged 37 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2507da9
Create Action to automatically set LGHA refs to an expected value; Cr…
davidpuplava Feb 9, 2024
61010f6
Remove empty lines from tag and release workflow
davidpuplava Feb 9, 2024
9c30364
Refactor based on feedback; Force push changes to tag
davidpuplava Feb 10, 2024
3641fd6
Merge remote-tracking branch 'origin/dev' into issue/OSOE-735
davidpuplava Feb 10, 2024
f2c1fbb
Handle special GHA refs such as spelling action that explicitly refer…
davidpuplava Feb 10, 2024
e7f93de
Remove extra whitespace
davidpuplava Feb 10, 2024
8d30e18
Merge branch 'dev' into issue/OSOE-735
davidpuplava Feb 14, 2024
def22e7
Refactor tag version to be reusable and take a secret; Add starter wo…
davidpuplava Feb 14, 2024
859c77d
Rmove whitespace
davidpuplava Feb 14, 2024
40dfb89
Merge branch 'dev' into issue/OSOE-735
davidpuplava Feb 20, 2024
9e8ae8c
Merge remote-tracking branch 'origin/dev' into issue/OSOE-735
BenedekFarkas Feb 28, 2024
c5281cc
Update readme to include information on automatic versioning
davidpuplava Mar 9, 2024
4ee3af6
Line wrap yaml descriptions to 120 characters
davidpuplava Mar 9, 2024
66de866
Surface the set-gha-refs action parameters up to workflow
davidpuplava Mar 9, 2024
08bf3cf
Lock external acation stefanzweifel/git-auto-commit-action to specifi…
davidpuplava Mar 9, 2024
eed4713
Add empty lines between steps for readability
davidpuplava Mar 9, 2024
ab3535e
Use LGHA Set-GitHubOutput script for output
davidpuplava Mar 9, 2024
32030b6
Update readme to link to externally used action, add spell check igno…
davidpuplava Mar 9, 2024
6802134
A bit of code styling/simplification
BenedekFarkas Mar 11, 2024
f19459c
Updating Readme wording in "Versioning, Tags and Releases" and a bit …
BenedekFarkas Mar 11, 2024
36bbcef
Simplify code, fix small bug with GitHub output key name
davidpuplava Mar 14, 2024
fd52bc0
Add paragraph about why we version LGHA and add clearer formating for…
davidpuplava Mar 14, 2024
e0ce7b5
Refactor external action ncipollo/release-action into internal action…
davidpuplava Mar 14, 2024
a102798
Fix spelling errors
davidpuplava Mar 14, 2024
ee31067
Update ref to publish-nuget action which changed in this OSOE-735
davidpuplava Mar 14, 2024
6fb17de
Remove trailing spaces to satisfy linting
davidpuplava Mar 14, 2024
1667cd2
Fix incorrect GitHub Action expression syntax
davidpuplava Mar 14, 2024
6c0127f
Fix path for setting up scripts
davidpuplava Mar 14, 2024
004e19b
Ensure repo is checked out before setting up scripts
davidpuplava Mar 14, 2024
2b47381
A bit of code styling in release-action
BenedekFarkas Mar 14, 2024
12492f3
Removing deprecated parameter from release-action
BenedekFarkas Mar 14, 2024
bbc033e
Minor wording improvement
BenedekFarkas Mar 14, 2024
05a109a
Simplify regex for GitHub Action references
davidpuplava Mar 15, 2024
4d5e3a8
Fix typo for matched line number
davidpuplava Mar 15, 2024
a954acd
Merge branch 'issue/OSOE-735' of https://github.com/Lombiq/GitHub-Act…
davidpuplava Mar 15, 2024
24f5ce6
Remove unused inputs copied from external GitHub Action for LGHA cent…
davidpuplava Mar 15, 2024
a4eaf75
Reverting branch references to dev
BenedekFarkas Mar 21, 2024
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
35 changes: 35 additions & 0 deletions .github/actions/set-gha-refs/Set-Called-GHA-Refs.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
param(
[String[]] $CalledRepoBaseIncludeList,
[String[]] $PathIncludeList,
[String[]] $FileIncludeList,
[String] $ExpectedRef
)

if ($CalledRepoBaseIncludeList.Count -eq 0)
{
Write-Output '::warning file=Check-Called-GHA-refs.ps1,line10::CalledRepoBaseIncludeList is empty which is unexpected. If this was intentional, you can ignore this warning.'
exit 0 # Nothing to check because array is empty.
}
BenedekFarkas marked this conversation as resolved.
Show resolved Hide resolved

$CalledRepoBaseIncludeList = $CalledRepoBaseIncludeList.ForEach({ 'uses:\s*' + $PSItem + '(.*)@(.*)' })
BenedekFarkas marked this conversation as resolved.
Show resolved Hide resolved

$matchedRefs = Get-ChildItem -Path $PathIncludeList -Include $FileIncludeList -Force -Recurse |
Select-String -Pattern $CalledRepoBaseIncludeList
BenedekFarkas marked this conversation as resolved.
Show resolved Hide resolved

if ($matchedRefs.Count -gt 0)
{

"These called GitHub Actions and Workflows have been explicitly set to ref '$ExpectedRef'." >> $env:GITHUB_STEP_SUMMARY

foreach ($matched in $matchedRefs)
{
$oldline = $matched.Line
$newline = $matched.Line -Replace '@(.*)', "@$ExpectedRef"
Write-Output $oldline
Write-Output $newline

$filename = $matched.RelativePath($pwd)

(Get-Content $filename).Replace($oldline, $newline) | Set-Content $filename
BenedekFarkas marked this conversation as resolved.
Show resolved Hide resolved
}
}
44 changes: 44 additions & 0 deletions .github/actions/set-gha-refs/action.yml
BenedekFarkas marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Set GitHub Actions References
description: >
Explicitly sets all called GitHub Action and Workflow references to an expected version.

inputs:
path-include-list:
required: false
default: '@(".github")'
description: >
PowerShell string array of paths, relative to the repository root, to search for GHA files, e.g. '@(".github")' or '@(".github/actions", ".github/workflows")'. The
parameter must be a PowerShell string array.
file-include-list:
required: false
default: '@("*.yml","*.yaml")'
description: >
PowerShell string array of file name patterns to include when evaluating GHA files, e.g. '@("*.yml")' or '@("*.yml", "*.yaml")'. The
parameter must be a PowerShell string array.
called-repo-base-include-list:
required: false
default: '@("${{ github.repository }}")'
description: >
PowerShell string array of repository base URLs to include when evaluating called GHA Workflows and Actions, e.g '@("Lombiq/GitHub-Actions")' or
'@("Lombiq/GitHub-Actions", "Lombiq/Open-Source-Orchard-Core-Extensions")'. The parameter must be a PowerShell string array.
expected-ref:
required: true
description: The expected reference value to set for all called GHA Workflows and Actions.
runs:
using: "composite"
steps:
- name: Setup
shell: pwsh
run: |
"${{ github.action_path }}" >> $Env:GITHUB_PATH

- name: Set References
shell: pwsh
run: |
$params = @{
PathIncludeList = ${{ inputs.path-include-list }}
FileIncludeList = ${{ inputs.file-include-list }}
CalledRepoBaseIncludeList = ${{ inputs.called-repo-base-include-list }}
ExpectedRef = "${{ inputs.expected-ref }}"
}
Set-Called-GHA-Refs @params
BenedekFarkas marked this conversation as resolved.
Show resolved Hide resolved
39 changes: 39 additions & 0 deletions .github/workflows/tag-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Tag and Release LGHA
on:
push:
branches:
- release/*

jobs:
run:
name: Update LGHA Refs
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository.
contents: write
steps:
- name: Checkout Repository
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev
with:
token: ${{ secrets.TAG_AND_RELEASE }}
Piedone marked this conversation as resolved.
Show resolved Hide resolved

- name: Determine Version Tag Name from Branch Name
id: determine-tag
shell: pwsh
run: |
$refname = "${{ github.ref_name }}"
$tagname = $refname -replace 'release/', ''
$output = "tagname=$tagname"
Write-Output "output=$output"
$output >> $env:GITHUB_OUTPUT

Check failure on line 29 in .github/workflows/tag-and-release.yml

View workflow job for this annotation

GitHub Actions / YAML Linting / YAML Linting Job

29:1 [trailing-spaces] trailing spaces
- name: Set Ref for GitHub Actions and Workflows
uses: Lombiq/GitHub-Actions/.github/actions/set-gha-refs@issue/OSOE-735
with:
expected-ref: '${{ steps.determine-tag.outputs.tagname }}'
BenedekFarkas marked this conversation as resolved.
Show resolved Hide resolved

- name: Commit and Push Changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update called GitHub Actions and Workflows to release version
tagging_message: ${{ steps.determine-tag.outputs.tagname }}
Loading