Skip to content

Commit 901b977

Browse files
committed
Fix build. Remove unnecessary files from output.
1 parent 5bcf039 commit 901b977

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ jobs:
3838
- name: "dotnet publish: ${{ env.VER_STR }}"
3939
run: dotnet publish Src\GitSimpleRewriteHistory.csproj --configuration Release -p:InformationalVersion="${{env.VER_STR}}" -p:Version=${{env.VER_NUM}} -p:FileVersion=${{env.VER_NUM}} -p:AssemblyVersion=${{env.VER_NUM}} -o Publish
4040

41+
- name: Cleanup
42+
shell: pwsh
43+
run: |
44+
Remove-Item -Path .\Publish\linux-* -Recurse -Force
45+
Remove-Item -Path .\Publish\osx-* -Recurse -Force
46+
4147
- name: Upload artifact
4248
uses: actions/upload-artifact@v4
4349
with:

.github/workflows/version.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module.exports = ({ context, github, firstRev }) => {
2+
const { execSync } = require('child_process');
3+
const fs = require('fs');
4+
5+
const d = new Date();
6+
const verGitRevs = !firstRev ? '0' : execSync(`git rev-list ${firstRev}.. --count`).toString().trim();
7+
8+
function formatVersion(template) {
9+
template = template.replaceAll("$(yyyy)", (d.getYear() + 1900).toString());
10+
template = template.replaceAll("$(yy)", (d.getYear() % 100).toString().padStart(2, '0'));
11+
template = template.replaceAll("$(mm)", (d.getMonth() + 1).toString().padStart(2, '0'));
12+
template = template.replaceAll("$(dd)", d.getDate().toString().padStart(2, '0'));
13+
template = template.replaceAll("$(GitRevCount)", verGitRevs);
14+
template = template.replaceAll("$(GitSha6)", String(process.env.GITHUB_SHA).substring(0, 6).toLowerCase());
15+
template = template.replaceAll("$(GitSha8)", String(process.env.GITHUB_SHA).substring(0, 8).toLowerCase());
16+
template = template.replaceAll("$(GitBranch)", context.ref.replace('refs/heads/', ''));
17+
template = template.replaceAll("$(RunNumber)", String(process.env.GITHUB_RUN_NUMBER));
18+
return template;
19+
}
20+
21+
function updateJson(filename, updateFunc) {
22+
var json = JSON.parse(fs.readFileSync(filename, 'utf8'));
23+
updateFunc(json);
24+
fs.writeFileSync(filename, JSON.stringify(json));
25+
}
26+
function updateText(filename, find, replace) {
27+
let str = fs.readFileSync(filename, 'utf8');
28+
if (str.indexOf(find) < 0)
29+
throw `Unable to find string "${find}" in file "${filename}"`;
30+
str = str.split(find).join(replace);
31+
fs.writeFileSync(filename, str);
32+
}
33+
34+
return {
35+
formatVersion,
36+
updateJson,
37+
updateText,
38+
};
39+
};

0 commit comments

Comments
 (0)