Skip to content

Commit

Permalink
Fix build. Remove unnecessary files from output.
Browse files Browse the repository at this point in the history
  • Loading branch information
rstarkov committed Oct 12, 2024
1 parent 5bcf039 commit 901b977
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ jobs:
- name: "dotnet publish: ${{ env.VER_STR }}"
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

- name: Cleanup
shell: pwsh
run: |
Remove-Item -Path .\Publish\linux-* -Recurse -Force
Remove-Item -Path .\Publish\osx-* -Recurse -Force
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = ({ context, github, firstRev }) => {
const { execSync } = require('child_process');
const fs = require('fs');

const d = new Date();
const verGitRevs = !firstRev ? '0' : execSync(`git rev-list ${firstRev}.. --count`).toString().trim();

function formatVersion(template) {
template = template.replaceAll("$(yyyy)", (d.getYear() + 1900).toString());
template = template.replaceAll("$(yy)", (d.getYear() % 100).toString().padStart(2, '0'));
template = template.replaceAll("$(mm)", (d.getMonth() + 1).toString().padStart(2, '0'));
template = template.replaceAll("$(dd)", d.getDate().toString().padStart(2, '0'));
template = template.replaceAll("$(GitRevCount)", verGitRevs);
template = template.replaceAll("$(GitSha6)", String(process.env.GITHUB_SHA).substring(0, 6).toLowerCase());
template = template.replaceAll("$(GitSha8)", String(process.env.GITHUB_SHA).substring(0, 8).toLowerCase());
template = template.replaceAll("$(GitBranch)", context.ref.replace('refs/heads/', ''));
template = template.replaceAll("$(RunNumber)", String(process.env.GITHUB_RUN_NUMBER));
return template;
}

function updateJson(filename, updateFunc) {
var json = JSON.parse(fs.readFileSync(filename, 'utf8'));
updateFunc(json);
fs.writeFileSync(filename, JSON.stringify(json));
}
function updateText(filename, find, replace) {
let str = fs.readFileSync(filename, 'utf8');
if (str.indexOf(find) < 0)
throw `Unable to find string "${find}" in file "${filename}"`;
str = str.split(find).join(replace);
fs.writeFileSync(filename, str);
}

return {
formatVersion,
updateJson,
updateText,
};
};

0 comments on commit 901b977

Please sign in to comment.