Skip to content

Commit 271b610

Browse files
authored
Merge pull request #36 from maliavko/dev
CI improvements, general bugfix
2 parents 52bc3b1 + e45fb97 commit 271b610

7 files changed

Lines changed: 70 additions & 37 deletions

File tree

.github/workflows/build-library.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ on:
2727
required: false
2828
default: false
2929
type: boolean
30+
build_num:
31+
required: true
32+
type: string
33+
version_tag:
34+
required: true
35+
type: string
3036

3137
jobs:
3238
build-spotifar:
@@ -104,7 +110,7 @@ jobs:
104110
env:
105111
VCPKG_FEATURE_FLAGS: "binarycaching" # Possibly redundant, but explicitly sets the binary caching feature flag
106112
VCPKG_BINARY_SOURCES: "clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite"
107-
run: cmake --preset ${{ matrix.platform }} -DBUILD_LIBRESPOT=${{inputs.build_librespot}} -DCMAKE_INSTALL_PREFIX=/install/${{ matrix.platform }} -DTESTING=${{ inputs.testing }}
113+
run: cmake --preset ${{ matrix.platform }} -DPLUGIN_VER_BUILD=${{ inputs.build_num }} -DBUILD_LIBRESPOT=${{ inputs.build_librespot }} -DCMAKE_INSTALL_PREFIX=/install/${{ matrix.platform }} -DTESTING=${{ inputs.testing }}
108114

109115
- name: Build spotifar
110116
run: cmake --build --preset ${{ matrix.platform }}-${{ inputs.build_type }} --target install --parallel $(nproc)
@@ -123,16 +129,17 @@ jobs:
123129
path: /install/${{ matrix.platform }}
124130

125131
- name: Pack spotifar
132+
if: inputs.upload_artifacts
126133
run: |
127-
powershell Compress-Archive -Path /install/${{ matrix.platform }}/* -DestinationPath /install/spotifar-${{ matrix.platform }}.zip
134+
powershell Compress-Archive -Path /install/${{ matrix.platform }}/* -DestinationPath /install/spotifar-${{ matrix.platform }}-${{ inputs.version_tag }}.zip
128135
129136
- name: Packaging artifacts
130137
if: inputs.upload_artifacts
131138
uses: actions/upload-artifact@v4
132139
with:
133140
name: spotifar-${{ matrix.platform }}
134-
path: /install/spotifar-${{ matrix.platform }}.zip
135-
141+
path: /install/spotifar-${{ matrix.platform }}-${{ inputs.version_tag }}.zip
142+
136143
# reporting
137144
- name: ccache statistics
138145
if: inputs.caching

.github/workflows/package-releases.yml

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,41 @@ on:
55
branches: [main]
66

77
jobs:
8+
get_version:
9+
runs-on: windows-latest
10+
outputs:
11+
build_num: ${{ steps.version.outputs.build_num }}
12+
tag: ${{ steps.version.outputs.tag }}
13+
14+
permissions:
15+
contents: read
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
fetch-tags: true
22+
23+
- name: Get version and label
24+
id: version
25+
run: |
26+
$version = (Select-String -Path CMakeLists.txt -Pattern 'project\(.*VERSION ([0-9\.]+)').Matches[0].Groups[1].Value
27+
$tag = git tag --sort=-taggerdate | Select-Object -Last 1
28+
if (-not $tag) { $build_num = 0 }
29+
else { $build_num = [int]($tag.Split('.')[-1]) }
30+
$next_build_num = $build_num + 1
31+
$full_version = "$version.$next_build_num"
32+
$new_tag_name = "v$full_version"
33+
34+
Write-Host "Latest tag: $tag"
35+
Write-Host "Build num: $build_num"
36+
Write-Host "Next build num: $next_build_num"
37+
Write-Host "Full version: $full_version"
38+
Write-Host "New tag: $new_tag_name"
39+
40+
echo "tag=$new_tag_name" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
41+
echo "build_num=$next_build_num" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
42+
843
build-librespot:
944
uses: ./.github/workflows/build-librespot.yml
1045
permissions:
@@ -16,7 +51,7 @@ jobs:
1651
secrets: inherit
1752

1853
build-spotifar:
19-
needs: build-librespot
54+
needs: [get_version, build-librespot]
2055
uses: ./.github/workflows/build-library.yml
2156
permissions:
2257
actions: read
@@ -26,37 +61,17 @@ jobs:
2661
build_librespot: false
2762
testing: false
2863
caching: false # no caching used for master releases
64+
build_num: ${{ needs.get_version.outputs.build_num }}
65+
version_tag: ${{ needs.get_version.outputs.tag }}
2966
secrets: inherit
3067

3168
packaging:
32-
needs: [build-librespot, build-spotifar]
69+
needs: [get_version, build-librespot, build-spotifar]
3370
runs-on: windows-latest
3471
permissions:
3572
actions: read
3673
contents: write
3774
steps:
38-
- uses: actions/checkout@v4
39-
with:
40-
fetch-depth: 0
41-
fetch-tags: true
42-
43-
- name: Get version and label
44-
id: get_version
45-
run: |
46-
$version = (Select-String -Path CMakeLists.txt -Pattern 'project\(.*VERSION ([0-9\.]+)').Matches[0].Groups[1].Value
47-
$tag = git tag --sort=-taggerdate
48-
Write-Host "Tag: $tag"
49-
if (-not $tag) { $build_num = 0 }
50-
else { $build_num = [int]($tag.Split('.')[-1]) }
51-
Write-Host "Build num: $build_num"
52-
$next_build_num = $build_num + 1
53-
Write-Host "Next build num: $next_build_num"
54-
$full_version = "$version.$next_build_num"
55-
Write-Host "Full version: $full_version"
56-
$new_tag_name = "v$full_version"
57-
Write-Host "Tag: $new_tag_name"
58-
echo "tag=$new_tag_name" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
59-
6075
- name: Download all artifacts
6176
uses: actions/download-artifact@v5
6277
with:
@@ -66,7 +81,7 @@ jobs:
6681
- name: Create GitHub Release
6782
uses: softprops/action-gh-release@v2
6883
with:
69-
tag_name: ${{ steps.get_version.outputs.tag }}
70-
name: Spotifar ${{ steps.get_version.outputs.tag }}
84+
tag_name: ${{ needs.get_version.outputs.tag }}
85+
name: Spotifar ${{ needs.get_version.outputs.tag }}
7186
files: artifacts/**/*
7287
generate_release_notes: true

.github/workflows/quick-build-and-test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ jobs:
1616
testing: true
1717
caching: true
1818
upload_artifacts: false
19+
build_num: '0' # not needed for testing
20+
version_tag: '' # not needed for testing
1921
secrets: inherit

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ set(PLUGIN_FILENAME "${PROJECT_NAME}.dll")
77
set(PLUGIN_DESC "A front-end client for listening to music from Spotify")
88
set(PLUGIN_AUTHOR "IgorM")
99
set(PLUGIN_VER_STAGE VS_RC)
10+
if(NOT DEFINED PLUGIN_VER_BUILD)
11+
set(PLUGIN_VER_BUILD "0")
12+
endif()
1013
# enum VERSION_STAGE
1114
# {
1215
# VS_RELEASE = 0,

src/hotkeys_handler.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ class hotkeys_handler:
2121
void volume_down(int step);
2222
void seek_forward(int step);
2323
void seek_backward(int step);
24+
25+
/// @brief In case there is no active device and Librespot is not active
26+
/// for any reason, this method provides a fallback solution to offer
27+
/// for user to pick up manually a device to tranfer playback to from the list
28+
/// of available
29+
void pick_up_any();
2430

2531
void tick();
2632
protected:
2733
/// @brief Returns a currently active device or nullptr
2834
auto get_active_device() const -> const spotify::device_t*;
2935

30-
/// @brief In case there is no active device and Librespot is not active
31-
/// for any reason, this method provides a fallback solution to offer
32-
/// for user to pick up manually a device to tranfer playback to from the list
33-
/// of available
34-
void pick_up_any();
35-
3636
// config handlers
3737
void on_global_hotkeys_setting_changed(bool is_enabled) override;
3838
void on_global_hotkey_changed(config::settings::hotkeys_t changed_keys) override;

src/plugin.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ void plugin::launch_librespot_process(const string &access_token)
157157
if (!librespot->is_running())
158158
{
159159
ui::hide_waiting();
160+
161+
// if the Librespot device is not running for whatever reason we are trying to pick up
162+
// any device, including the offer for user to pick from the list
163+
hotkeys->pick_up_any();
160164
}
161165
else
162166
{

src/version.hpp.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#define PLUGIN_NAME L"@PLUGIN_NAME@"
1111
#define PLUGIN_FILENAME L"@PLUGIN_FILENAME@"
1212
#define PLUGIN_AUTHOR L"@PLUGIN_AUTHOR@"
13-
#define PLUGIN_VERSION MAKEFARVERSION(@spotifar_VERSION_MAJOR@,@spotifar_VERSION_MINOR@,@spotifar_VERSION_PATCH@,0,(VERSION_STAGE)@PLUGIN_VER_STAGE@)
13+
// for some reason in far UI the version is shown in the mixed way: major.minor.build.revision, I swapped these components
14+
// here so the version in Far UI matches the one on Github
15+
#define PLUGIN_VERSION MAKEFARVERSION(@spotifar_VERSION_MAJOR@,@spotifar_VERSION_MINOR@,@PLUGIN_VER_BUILD@,@spotifar_VERSION_PATCH@,(VERSION_STAGE)@PLUGIN_VER_STAGE@)
1416

1517
#endif // VERSION_HPP_190BAC0F_2C12_4955_932E_7A1D19EBC744

0 commit comments

Comments
 (0)