Skip to content

Commit

Permalink
categorize updates and generate commit messages
Browse files Browse the repository at this point in the history
  • Loading branch information
moonshadow565 committed Aug 27, 2022
1 parent 7cd91b3 commit 4b70b07
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 25 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,31 @@ jobs:
run: |
./make-release.sh build
7z a cslol-manager-windows.exe -sfx7z.sfx cslol-manager/
- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v3
with:
failOnError: 'true'
commitMode: 'true'
toTag: ${{ github.ref_name }}
configurationJson: |
{
"tag_resolver": {
"method": "sort",
"filter": {
"pattern": "\\d+-\\d+-\\d+-.+",
"flags": "gu"
}
},
"pr_template": "- #{{MERGE_SHA}}: #{{TITLE}}",
"template": "#{{UNCATEGORIZED}}"
}
ignorePreReleases: ${{ endsWith(github.ref_name, '-prerelease') || endsWith(github.ref_name, '-test') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Release"
uses: softprops/action-gh-release@v1
with:
files: cslol-manager-windows.exe
prerelease: ${{ endsWith(github.ref_name, '-prerelease') || endsWith(github.ref_name, '-test') }}
body: ${{ steps.github_release.outputs.changelog }}
3 changes: 2 additions & 1 deletion make-release-remote.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
REMOTE=${1:-origin}
VERSION=$(git log --date=short --format="%ad-%h" -1)
SUFFIX="${2}"
VERSION=$(git log --date=short --format="%ad-%h" -1)${SUFFIX}
echo "Version: $VERSION"
git tag $VERSION
git push --tags $REMOTE $VERSION
11 changes: 6 additions & 5 deletions src/qml/CSLOLDialogSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Dialog {
property bool isBussy: false
property alias blacklist: blacklistCheck.checked
property alias ignorebad: ignorebadCheck.checked
property alias disableUpdates: disableUpdatesCheck.checked
property alias enableUpdates: enableUpdatesCheck.checkState
property alias themeDarkMode: themeDarkModeCheck.checked
property alias themePrimaryColor: themePrimaryColorBox.currentIndex
property alias themeAccentColor: themeAccentColorBox.currentIndex
Expand Down Expand Up @@ -121,10 +121,11 @@ Dialog {
onClicked: Qt.openUrlExternally(cslolDialogUpdate.update_url)
Layout.fillWidth: true
}
Switch {
id: disableUpdatesCheck
text: qsTr("Disable updates")
checked: false
CheckBox {
id: enableUpdatesCheck
text: qsTr("Enable updates")
checkState: Qt.PartiallyChecked
tristate: true
Layout.fillWidth: true
}
Switch {
Expand Down
51 changes: 34 additions & 17 deletions src/qml/CSLOLDialogUpdate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Dialog {
}
}

property bool disableUpdates: false
property int enableUpdates: Qt.PartiallyChecked

function makeRequest(url, onDone) {
let request = new XMLHttpRequest();
Expand All @@ -44,25 +44,42 @@ Dialog {

function checkForUpdates() {
let url = "https://api.github.com/repos/LoL-Fantome/cslol-manager";
makeRequest(url + "/releases/latest", function(latest) {
if (disableUpdates && !(latest["body"].includes("mandatory") || latest["body"].includes("important"))) {
return;
}
let tag_name = latest["tag_name"];
makeRequest(url + "/git/ref/tags/" + tag_name, function(ref) {
let commit_sha = ref["object"]["sha"];
let commit_url = ref["object"]["url"];
if (commit_sha === CSLOL_COMMIT) {
return;
makeRequest(url + "/releases", function(releases) {
for (let release in releases) {
switch (enableUpdates) {
case Qt.Unchecked:
// recieve only mandatory updates
if (release["prerelease"] || !release["body"].includes("mandatory")) {
continue;
}
break;
case Qt.PartiallyChecked:
// only receive non-prerelease updates
if (release["prerelease"]) {
continue;
}
break;
case Qt.Checked:
// allways receive the update
break;
}
makeRequest(commit_url, function(commit) {
let current_date = Date.parse(CSLOL_DATE)
let commit_date = Date.parse(commit["committer"]["date"]);
if (commit_date > current_date) {
cslolDialogUpdate.open();
let tag_name = release["tag_name"];
console.log("Fetching release " + tag_name)
makeRequest(url + "/git/ref/tags/" + tag_name, function(ref) {
let commit_sha = ref["object"]["sha"];
let commit_url = ref["object"]["url"];
if (commit_sha === CSLOL_COMMIT) {
return;
}
makeRequest(commit_url, function(commit) {
let current_date = Date.parse(CSLOL_DATE)
let commit_date = Date.parse(commit["committer"]["date"]);
if (commit_date > current_date) {
cslolDialogUpdate.open();
}
})
})
})
}
})
}
}
4 changes: 2 additions & 2 deletions src/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ApplicationWindow {
property alias blacklist: cslolDialogSettings.blacklist
property alias ignorebad: cslolDialogSettings.ignorebad
property alias suppressInstallConflicts: cslolDialogSettings.suppressInstallConflicts
property alias disableUpdates: cslolDialogSettings.disableUpdates
property alias enableUpdates: cslolDialogSettings.enableUpdates
property alias enableAutoRun: cslolDialogSettings.enableAutoRun
property alias enableSystray: cslolDialogSettings.enableSystray
property alias themeDarkMode: cslolDialogSettings.themeDarkMode
Expand Down Expand Up @@ -304,7 +304,7 @@ ApplicationWindow {

CSLOLDialogUpdate {
id: cslolDialogUpdate
disableUpdates: settings.disableUpdates
enableUpdates: settings.enableUpdates
}

CSLOLTools {
Expand Down

0 comments on commit 4b70b07

Please sign in to comment.