Skip to content

Commit

Permalink
Merge pull request YARC-Official#8 from Pantotone/use-commit-count-in…
Browse files Browse the repository at this point in the history
…stead-of-hash

feat(nightly): use commit count instead of commit hash
  • Loading branch information
Pantotone authored Jan 22, 2024
2 parents 8a2e809 + 28f9cde commit ea8f323
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 29 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/nightly-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: ./.github/workflows/build-Linux.yml
secrets: inherit
with:
versionName: ${{ needs.check.outputs.latestSHA }}
versionName: ${{ needs.check.outputs.tagName }}
buildType: 'nightly'

mac-builder:
Expand All @@ -35,7 +35,7 @@ jobs:
uses: ./.github/workflows/build-Mac.yml
secrets: inherit
with:
versionName: ${{ needs.check.outputs.latestSHA }}
versionName: ${{ needs.check.outputs.tagName }}
buildType: 'nightly'

windows-builder:
Expand All @@ -46,7 +46,7 @@ jobs:
uses: ./.github/workflows/build-Windows.yml
secrets: inherit
with:
versionName: ${{ needs.check.outputs.latestSHA }}
versionName: ${{ needs.check.outputs.tagName }}
buildType: 'nightly'

publish:
Expand All @@ -64,7 +64,7 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
release_name: Nightly Build - ${{ needs.check.outputs.latestSHA }}
release_name: Nightly Build - ${{ needs.check.outputs.tagName }}
tag: ${{ needs.check.outputs.tagName }}
file: builds/*
file_glob: true
Expand Down
24 changes: 12 additions & 12 deletions methods/CheckLatestRelease.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { BLEEDINGEDGE_REPOSITORYAUTHOR, BLEEDINGEDGE_REPOSITORYNAME, YARG_DEVBRA
import * as core from '@actions/core';

const latestRelease = await GetLatestRelease(BLEEDINGEDGE_REPOSITORYAUTHOR, BLEEDINGEDGE_REPOSITORYNAME);
const latestDevCommit = await GetLatestCommit(YARG_ORGANIZATIONNAME, YARG_GAMEREPOSITORY, YARG_DEVBRANCH);
const devCommits = await GetCommits(YARG_ORGANIZATIONNAME, YARG_GAMEREPOSITORY, YARG_DEVBRANCH, latestRelease.published_at);
const latestDevCommit = devCommits.commits[0];
const nightlyVersionName = `b${devCommits?.branchCommitCount}`;

function FindIfLastestCommitHasBuild(release, platform = process.env.PLATFORM) {
const sha = latestDevCommit.sha;
const assetName = `YARG_${sha}-${platform}`;
function checkReleasePlatformBuild(release, platform = process.env.PLATFORM) {
const assetName = `YARG_${nightlyVersionName}-${platform}`;

const index = release.assets.findIndex(asset =>
asset.name
Expand All @@ -19,9 +19,9 @@ function FindIfLastestCommitHasBuild(release, platform = process.env.PLATFORM) {
return index >= 0;
}

core.setOutput("macBuild", !FindIfLastestCommitHasBuild(latestRelease, "MacOS"));
core.setOutput("windowsBuild", !FindIfLastestCommitHasBuild(latestRelease, "Windows"));
core.setOutput("linuxBuild", !FindIfLastestCommitHasBuild(latestRelease, "Linux"));
core.setOutput("macBuild", !checkReleasePlatformBuild(latestRelease, "MacOS"));
core.setOutput("windowsBuild", !checkReleasePlatformBuild(latestRelease, "Windows"));
core.setOutput("linuxBuild", !checkReleasePlatformBuild(latestRelease, "Linux"));

/**
* Takes all messages from commits and format them to the release message body;
Expand All @@ -34,7 +34,7 @@ function formatMessages(devCommits) {
};

const messageBody =
`Built using the commit https://github.com/${YARG_ORGANIZATIONNAME}/${YARG_GAMEREPOSITORY}/commit/${latestDevCommit.sha}
`Built using the commit https://github.com/${YARG_ORGANIZATIONNAME}/${YARG_GAMEREPOSITORY}/commit/${latestDevCommit?.oid}
### ⚠️ This build is an extremely early beta, so bugs are expected. ⚠️
Expand All @@ -45,9 +45,9 @@ Downloads are below.
## 📋 Commits
${formatMessages(devCommits)}
${formatMessages(devCommits.commits)}
`;

core.setOutput("messageBody", devCommits.length > 0 ? messageBody : latestRelease.body);
core.setOutput("latestSHA", latestDevCommit.sha);
core.setOutput("tagName", latestDevCommit.sha.substring(0, 7));
core.setOutput("messageBody", devCommits.commits.length > 0 ? messageBody : latestRelease.body);
core.setOutput("latestSHA", latestDevCommit?.oid);
core.setOutput("tagName", nightlyVersionName);
26 changes: 16 additions & 10 deletions utils/Github.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,19 @@ export async function GetCommits(repositoryAuthor, repositoryName, branch, since
ref(qualifiedName:$branch) {
target {
... on Commit {
branchCommitCount: history(first: 0) {
totalCount
},
history(first: 100, since:$since) {
nodes {
oid,
author {
user {
login
}
},
messageHeadline
}
nodes {
oid,
author {
user {
login
}
},
messageHeadline
}
}
}
}
Expand All @@ -75,7 +78,10 @@ export async function GetCommits(repositoryAuthor, repositoryName, branch, since
since
});

return data.repository.ref.target.history.nodes;
return {
branchCommitCount: data.repository.ref.target.branchCommitCount.totalCount,
commits: data.repository.ref.target.history.nodes
};
}

/**
Expand Down
6 changes: 3 additions & 3 deletions utils/const.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const GITHUB_API_ROOT = "https://api.github.com/";

export const YARG_ORGANIZATIONNAME = process.env.REPOSITORY_AUTHOR;
export const YARG_GAMEREPOSITORY = process.env.REPOSITORY_NAME;
export const YARG_DEVBRANCH = process.env.REPOSITORY_BRANCH;
export const YARG_ORGANIZATIONNAME = process.env.REPOSITORY_AUTHOR || "YARC-Official";
export const YARG_GAMEREPOSITORY = process.env.REPOSITORY_NAME || "YARG";
export const YARG_DEVBRANCH = process.env.REPOSITORY_BRANCH || "dev";

export const BLEEDINGEDGE_REPOSITORYAUTHOR = process.env.BLEEDINGEDGE_REPOSITORYAUTHOR || YARG_ORGANIZATIONNAME || "YARC-Official";
export const BLEEDINGEDGE_REPOSITORYNAME = process.env.BLEEDINGEDGE_REPOSITORYNAME || "YARG-BleedingEdge";

0 comments on commit ea8f323

Please sign in to comment.