Skip to content

Commit fb9fe3f

Browse files
authored
v1.1.0 (#1)
## <a href="https://github.com/GruberMarkus/Export-RecipientPermissions/releases/tag/v1.1.0" target="_blank">v1.1.0</a> - 2022-02-23 ### Added - Massive performance improvements, less RAM and network usage - Documentation - Command-line parameters - Sample code: Permission changes over time - Sample code: Get dependent recipients to support migrations to Exchange Online as not all permissions work cross-premises, or to graphically document existing permissions
1 parent 4bd6558 commit fb9fe3f

32 files changed

+2892
-1432
lines changed

.gitattributes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# exclude .gitignore and similar from the generated tarball
2+
/.git export-ignore
3+
/.github export-ignore
4+
/build export-ignore
5+
/docs export-ignore
6+
/src export-ignore
7+
/.gitattributes export-ignore

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
# Maintain dependencies for GitHub Actions
4+
- package-ecosystem: 'github-actions'
5+
directory: '/'
6+
schedule:
7+
interval: 'daily'
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: build, draft release
2+
on:
3+
push:
4+
# tags:
5+
# - "v*"
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
runs-on: windows-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Install GitVersion
18+
uses: gittools/actions/gitversion/[email protected]
19+
with:
20+
versionSpec: "5.x"
21+
22+
- name: Determine SemVer
23+
uses: gittools/actions/gitversion/[email protected]
24+
with:
25+
additionalArguments: '/overrideconfig major-version-bump-message="^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)" /overrideconfig minor-version-bump-message="^(feat)(\\([\\w\\s]*\\))?:" /overrideconfig patch-version-bump-message="^(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s]*\\))?:"'
26+
27+
- name: Display SemVer
28+
run: |
29+
write-output "SemVer: $env:GITVERSION_SEMVER"
30+
31+
- name: Get tag name
32+
run: |
33+
if ($($env:GITHUB_REF).startswith("refs/tags/")) {
34+
$ReleaseTag = ($env:GITHUB_REF -replace 'refs/tags/', '')
35+
} else {
36+
$ReleaseTag = "v$($env:GITVERSION_SEMVER)"
37+
}
38+
"RELEASETAG=$ReleaseTag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
39+
Write-Output "ReleaseTag: $ReleaseTag"
40+
41+
- name: Build
42+
run: build/build.ps1
43+
44+
- name: Create Release
45+
uses: ncipollo/release-action@v1
46+
with:
47+
tag: ${{ env.RELEASETAG }}
48+
commit: ${{ env.GITHUB_SHA }}
49+
artifactErrorsFailBuild: true
50+
artifacts: |
51+
${{ env.RELEASEFILE }}
52+
bodyFile: build/CHANGELOG.md
53+
draft: true
54+
name: ${{ env.RELEASENAME }}
55+
prerelease: true
56+
replacesArtifacts: true
57+
token: ${{ secrets.GITHUB_TOKEN }}

Export-RecipientPermissions.ps1

Lines changed: 0 additions & 1100 deletions
This file was deleted.

Get-DependentRecipients.ps1

Lines changed: 0 additions & 246 deletions
This file was deleted.

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Markus Gruber, all rights reserved
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

OUs.csv

Lines changed: 0 additions & 5 deletions
This file was deleted.

README.md

Lines changed: 0 additions & 81 deletions
This file was deleted.

build/build.ps1

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
function main {
2+
Write-Output 'Basics'
3+
Set-Location $env:GITHUB_WORKSPACE
4+
5+
& choco.exe install pandoc --no-progress
6+
refreshenv
7+
8+
if ($env:RELEASETAG) {
9+
$ReleaseTag = $env:RELEASETAG
10+
} else {
11+
$ReleaseTag = ($env:GITHUB_REF -replace 'refs/tags/', '')
12+
"RELEASETAG=$ReleaseTag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
13+
}
14+
15+
if ($env:RELEASEFILE) {
16+
$ReleaseFile = $env:RELEASEFILE
17+
} else {
18+
$ReleaseFile = ($env:GITHUB_REPOSITORY -split '/')[1] + '_' + $ReleaseTag + '.zip'
19+
"RELEASEFILE=$ReleaseFile" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
20+
}
21+
22+
if ($env:RELEASENAME) {
23+
$ReleaseName = $env:RELEASENAME
24+
} else {
25+
$ReleaseName = "Release $ReleaseTag"
26+
"RELEASENAME=$ReleaseName" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
27+
}
28+
29+
$BuildDir = $('./build/' + ($env:GITHUB_REPOSITORY -split '/')[1]) + '_' + $ReleaseTag
30+
New-Item $BuildDir -ItemType 'directory' | Out-Null
31+
32+
Write-Output "BuildDir: $BuildDir"
33+
Write-Output "ReleaseFile: $ReleaseFile"
34+
Write-Output "ReleaseName: $ReleaseName"
35+
Write-Output "ReleaseTag: $ReleaseTag"
36+
37+
38+
Write-Output 'Copy basic files'
39+
Set-Location $env:GITHUB_WORKSPACE
40+
41+
Copy-Item '.\src\*' $BuildDir -Recurse
42+
Copy-Item '.\LICENSE.txt' "$BuildDir\LICENSE.txt" -Force
43+
44+
45+
Write-Output 'Convert markdown files to HTML and copy them'
46+
Set-Location $env:GITHUB_WORKSPACE
47+
48+
@(
49+
('.\docs\CHANGELOG.md', "$BuildDir\docs\CHANGELOG.html"),
50+
('.\docs\CODE_OF_CONDUCT.md', "$BuildDir\docs\CODE_OF_CONDUCT.html"),
51+
('.\docs\CONTRIBUTING.md', "$BuildDir\docs\CONTRIBUTING.html"),
52+
('.\docs\README.md', "$BuildDir\docs\README.html")
53+
) | ForEach-Object {
54+
# update version number
55+
$tempFileContent = Get-Content $($_[0]) -Raw
56+
$tempFileContent = $tempFileContent -replace 'XXXVersionStringXXX', ($ReleaseTag.replace('-', '--').replace('_', '__').replace(' ', '_'))
57+
$tempFileContent = $tempFileContent -replace '<!--XXXRemoveWhenBuildingXXX', ''
58+
$tempFileContent = $tempFileContent -replace 'XXXRemoveWhenBuildingXXX-->', ''
59+
$tempFileContent | Set-Content $($_[0])
60+
# convert to HTML
61+
& pandoc.exe $($_[0]) --resource-path=".;docs" -f gfm -t html --self-contained -H .\build\pandoc_header.html --css .\build\pandoc_css_empty.css --metadata pagetitle="$(([System.IO.FileInfo]"$($_[0])").basename) - $(($env:GITHUB_REPOSITORY -split '/')[1])" -o $($_[1])
62+
}
63+
64+
65+
Write-Output 'Update version number in script'
66+
Set-Location $env:GITHUB_WORKSPACE
67+
68+
Set-Location $BuildDir
69+
70+
((Get-Content Export-RecipientPermissions.ps1 -Raw) -replace 'XXXVersionStringXXX', $ReleaseTag) | Set-Content Export-RecipientPermissions.ps1
71+
72+
73+
Write-Output 'Create file hashes and place them in file hashes.txt'
74+
Set-Location $env:GITHUB_WORKSPACE
75+
76+
Set-Location $BuildDir
77+
78+
Remove-Item 'hashes.txt' -Force
79+
80+
$Hashes = ForEach ($File in (Get-ChildItem -File -Recurse)) {
81+
Get-FileHash -LiteralPath $File.FullName -Algorithm SHA256 | Select-Object @{N = 'PathRelative'; E = { Resolve-Path -LiteralPath $file.FullName -Relative } }, Algorithm, Hash
82+
}
83+
84+
$Hashes | Export-Csv hashes.txt
85+
86+
87+
Write-Output 'Create release file'
88+
Set-Location $env:GITHUB_WORKSPACE
89+
90+
Compress-Archive $BuildDir $ReleaseFile
91+
92+
93+
Write-Output 'Output additional information for release'
94+
Set-Location $env:GITHUB_WORKSPACE
95+
96+
$Changelog = '.\docs\changelog.md'
97+
$ChangeLogLines = Get-Content $Changelog
98+
$ChangelogStartline = $null
99+
$ChangelogEndline = $null
100+
$ReleaseTagDate = $(Get-Date -Format 'yyyy-MM-dd')
101+
for ($i = 0; $i -lt $ChangeLogLines.count; $i++) {
102+
if (-not $ChangelogStartline) {
103+
if ($ChangeLogLines[$i] -match ("^##\s*(\[$ReleaseTag\] - $ReleaseTagDate\s*|$ReleaseTag - $ReleaseTagDate\s*|$ReleaseTag - $ReleaseTagDate$)|>$ReleaseTag</a> - $ReleaseTagDate\s*")) {
104+
$ChangelogStartline = $i
105+
continue
106+
}
107+
} else {
108+
if (($ChangeLogLines[$i]).startswith('## ')) {
109+
$ChangelogEndline = $i - 1
110+
break
111+
}
112+
}
113+
}
114+
if (-not $ChangelogStartline) {
115+
$ReleaseMarkdown = "# **Tag '$ReleaseTag - $ReleaseTagDate' not found in '$Changelog', using first entry.**`r`n"
116+
$ChangelogStartline = $null
117+
$ChangelogEndline = $null
118+
for ($i = 0; $i -lt $ChangeLogLines.count; $i++) {
119+
if (-not $ChangelogStartline) {
120+
if (($ChangeLogLines[$i]).startswith('## ')) {
121+
$ChangelogStartline = $i
122+
}
123+
} else {
124+
if (($ChangeLogLines[$i]).startswith('## ')) {
125+
$ChangelogEndline = $i - 1
126+
break
127+
}
128+
}
129+
}
130+
} else {
131+
if (-not $Changelogendline) { $ChangelogEndline = $ChangelogLines.count - 1 }
132+
}
133+
for ($i = $ChangelogStartline; $i -le $ChangelogEndline; $i++) {
134+
$ChangeLogLines[$i] = $ChangeLogLines[$i] -replace '^##', '#'
135+
}
136+
$ReleaseMarkdown = $ReleaseMarkdown + ($($ChangeLogLines[$ChangelogStartline..$ChangelogEndline]) -join "`r`n")
137+
138+
if ($RegExMatches = [regex]::matches($ReleaseMarkdown, '\[(.*?)\]')) {
139+
for ($i = 0; $i -lt $ChangeLogLines.count; $i++) {
140+
foreach ($m in $RegExMatches) {
141+
if ($ChangeLogLines[$i].StartsWith("$($m.value):")) {
142+
$ReleaseMarkdown = $ReleaseMarkdown + "`r`n$($ChangeLogLines[$i])"
143+
}
144+
}
145+
}
146+
}
147+
148+
$ReleaseMarkdown = $ReleaseMarkdown + @"
149+
`r`n# File hashes
150+
- SHA256 hash of '$ReleaseFile': $((Get-FileHash $ReleaseFile -Algorithm SHA256).hash)
151+
- See 'hashes.txt' in '$ReleaseFile' for hash value of every single file in the release.
152+
"@
153+
154+
Write-Output 'ReleaseMarkdown:'
155+
Write-Output $ReleaseMarkdown
156+
$ReleaseMarkdown | Out-File -FilePath .\build\CHANGELOG.md -Encoding utf8 -Force
157+
}
158+
159+
if ($env:GITHUB_WORKSPACE) {
160+
main
161+
} else {
162+
throw 'This script is designed to run as part of a GitHub workflow, and does not work elsewhere.'
163+
}

0 commit comments

Comments
 (0)