Repository navigation
109 lines (96 loc) · 3.51 KB
/
Copy pathrelease.yml
File metadata and controls
109 lines (96 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Auto Release on Version Change
on:
push:
branches: [ master ]
paths:
- 'build.gradle'
jobs:
check-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
version-changed: ${{ steps.check-tag.outputs.changed }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Extract version from build.gradle
id: get-version
run: |
VERSION=$(grep "^version " build.gradle | sed "s/version '\(.*\)'/\1/")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Detected version: $VERSION"
- name: Check if tag exists
id: check-tag
run: |
VERSION=${{ steps.get-version.outputs.version }}
if git rev-parse "refs/tags/$VERSION" >/dev/null 2>&1; then
echo "Tag $VERSION already exists"
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "Tag $VERSION does not exist - new version detected"
echo "changed=true" >> $GITHUB_OUTPUT
fi
native-windows:
needs: check-version
if: needs.check-version.outputs.version-changed == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- name: Set up Rust
uses: dtolnay/rust-toolchain@599c45df1a24c1c63ae1129a7e59f46654b8fb66 # 1.89.0
with:
targets: x86_64-pc-windows-msvc
- name: Install Windows cross-compiler
run: cargo install cargo-xwin --version 0.23.1 --locked
- name: Build Windows native library
run: cargo xwin build --manifest-path rust/Cargo.toml --release --lib --locked --target x86_64-pc-windows-msvc
env:
XWIN_ACCEPT_LICENSE: '1'
- name: Upload Windows native library
uses: actions/upload-artifact@v6
with:
name: windowsmediacontrol
path: rust/target/x86_64-pc-windows-msvc/release/windowsmediacontrol.dll
if-no-files-found: error
release:
needs: [check-version, native-windows]
if: needs.check-version.outputs.version-changed == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Use native library built from this commit
uses: actions/download-artifact@v6
with:
name: windowsmediacontrol
path: native-artifacts
- name: Set up JDK 26
uses: actions/setup-java@v6
with:
java-version: '26'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build -PwindowsNativeDll=native-artifacts/windowsmediacontrol.dll
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.check-version.outputs.version }}
name: ${{ needs.check-version.outputs.version }}
generate_release_notes: true
draft: false
prerelease: false
files: |
build/libs/java-spotify-api-${{ needs.check-version.outputs.version }}.jar
build/libs/java-spotify-api-${{ needs.check-version.outputs.version }}-all.jar
build/libs/java-spotify-api-${{ needs.check-version.outputs.version }}-javadoc.jar
build/libs/java-spotify-api-${{ needs.check-version.outputs.version }}-sources.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}