Skip to content

Commit 15e44d4

Browse files
Merge pull request #184 from usefulness/mateuszkwiecinski-patch-1
Test on macos-latest + authenticate requests
2 parents 6a8894b + b2ab838 commit 15e44d4

6 files changed

Lines changed: 34 additions & 14 deletions

File tree

.github/workflows/main.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
java-version: 23
2424

2525
- name: Downgrade dependency version to see the diff
26+
if: runner.os != 'macOS'
2627
run: sed -i -E 's/androidx.paging:paging-common-ktx:[[:digit:]]+.[[:digit:]]+.[[:digit:]]+/androidx.paging:paging-common-ktx:3.2.0/g' testproject/build.gradle
2728

2829
- uses: gradle/actions/setup-gradle@v4
@@ -145,7 +146,7 @@ jobs:
145146
strategy:
146147
fail-fast: false
147148
matrix:
148-
os: [ macos-14, windows-latest, ubuntu-latest]
149+
os: [ macos-latest, windows-latest, ubuntu-latest]
149150
runs-on: ${{ matrix.os }}
150151
name: Execute on ${{ matrix.os }} runner
151152
steps:
@@ -159,9 +160,13 @@ jobs:
159160
java-version: 23
160161

161162
- name: Downgrade dependency version to see the diff (Unix)
162-
if: runner.os != 'Windows'
163+
if: runner.os != 'Windows' && runner.os != 'macOS'
163164
run: sed -i -E 's/androidx.paging:paging-common-ktx:[[:digit:]]+.[[:digit:]]+.[[:digit:]]+/androidx.paging:paging-common-ktx:3.2.0/g' testproject/build.gradle
164165

166+
- name: Downgrade dependency version to see the diff (macOS)
167+
if: runner.os == 'macOS'
168+
run: sed -i '' -E 's/androidx.paging:paging-common-ktx:[[:digit:]]+.[[:digit:]]+.[[:digit:]]+/androidx.paging:paging-common-ktx:3.2.0/g' testproject/build.gradle
169+
165170
- name: Downgrade dependency version to see the diff (Windows)
166171
if: runner.os == 'Windows'
167172
run: |

Readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Dependency Tree Diff - Github Action
1+
# Dependency Tree Diff - GitHub Action
22

33
![.github/workflows/main.yml](https://github.com/usefulness/dependency-tree-diff-action/workflows/.github/workflows/main.yml/badge.svg)
44

5-
Simple Github Action wrapper for Jake Wharton's [Dependency Tree Diff](https://github.com/JakeWharton/dependency-tree-diff) tool.
5+
Simple GitHub Action wrapper for Jake Wharton's [Dependency Tree Diff](https://github.com/JakeWharton/dependency-tree-diff) tool.
66

77
## Usage
8-
The action only exposes _output_ containing the diff, so to effectively consume its output it is highly recommended to use other Github Actions to customize your experience.
8+
The action only exposes _output_ containing the diff, so to effectively consume its output, it is highly recommended to use other GitHub Actions to customize your experience.
99

1010
#### Create Pull Request comment on dependency change
1111
[See it in action!](https://github.com/mateuszkwiecinski/github_browser/pull/31)
@@ -69,7 +69,7 @@ All inputs with their default values:
6969
```
7070
7171
- **`configuration`** - Selected Gradle configuration, passed to `./gradlew dependencies --configuration xxx`.
72-
Should correspond to output artifact that is considered output of the project.
72+
It should correspond to output artifact considered output of the project.
7373
- **`project`** - Gradle project which dependency tree diff should be generated for.
7474
Dependency diff for root projects can be configured using `project: ''`.
7575
For Android projects use the one that has `com.android.application` plugin applied.

action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ runs:
5454
INPUT_VERSION: ${{ inputs.lib-version }}
5555
INPUT_ADDITIONAL_GRADLE_ARGUMENTS: ${{ inputs.additional-gradle-arguments }}
5656
INPUT_DEBUG: ${{ inputs.debug }}
57+
GITHUB_TOKEN: ${{ github.token }}
5758
run: $GITHUB_ACTION_PATH/entrypoint.sh
5859
shell: bash
5960

@@ -67,5 +68,6 @@ runs:
6768
INPUT_VERSION: ${{ inputs.lib-version }}
6869
INPUT_ADDITIONAL_GRADLE_ARGUMENTS: ${{ inputs.additional-gradle-arguments }}
6970
INPUT_DEBUG: ${{ inputs.debug }}
71+
GITHUB_TOKEN: ${{ github.token }}
7072
run: "& \"$env:GITHUB_ACTION_PATH/entrypoint.ps1\""
7173
shell: pwsh

entrypoint.ps1

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,25 @@ param(
55
[string]$InputBuildRootDir = $env:INPUT_BUILD_ROOT_DIR,
66
[string]$InputVersion = $env:INPUT_VERSION,
77
[string]$InputAdditionalGradleArguments = $env:INPUT_ADDITIONAL_GRADLE_ARGUMENTS,
8-
[string]$InputDebug = $env:INPUT_DEBUG
8+
[string]$InputDebug = $env:INPUT_DEBUG,
9+
[string]$GithubToken = $env:GITHUB_TOKEN
910
)
1011

1112
$ErrorActionPreference = "Stop"
1213

1314
Set-Location $InputBuildRootDir
1415

16+
$headers = @{
17+
Authorization = "Bearer $GithubToken"
18+
}
19+
1520
if ($InputVersion -eq "latest") {
16-
$latestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/JakeWharton/dependency-tree-diff/releases/latest"
21+
$latestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/JakeWharton/dependency-tree-diff/releases/latest" -Headers $headers
1722
$downloadUrl = $latestRelease.assets | Where-Object { $_.name -eq "dependency-tree-diff.jar" } | Select-Object -ExpandProperty browser_download_url
18-
Invoke-WebRequest -Uri $downloadUrl -OutFile "dependency-tree-diff.jar"
23+
Invoke-WebRequest -Uri $downloadUrl -Headers $headers -OutFile "dependency-tree-diff.jar"
1924
} else {
2025
$downloadUrl = "https://github.com/JakeWharton/dependency-tree-diff/releases/download/$InputVersion/dependency-tree-diff.jar"
21-
Invoke-WebRequest -Uri $downloadUrl -OutFile "dependency-tree-diff.jar"
26+
Invoke-WebRequest -Uri $downloadUrl -Headers $headers -OutFile "dependency-tree-diff.jar"
2227
}
2328

2429
if ($InputProject -eq ":") {
@@ -29,6 +34,7 @@ if ($InputDebug -eq "true") {
2934
Write-Host "download finished"
3035
Write-Host "JAVA_HOME: $env:JAVA_HOME"
3136
java -version
37+
Get-Location
3238
}
3339

3440
$currentHead = git rev-parse HEAD
@@ -61,4 +67,4 @@ $headPath = Resolve-Path "dependency-tree-diff_dependencies-head.txt"
6167
"file-dependencies-base=$basePath" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding UTF8
6268
"file-dependencies-head=$headPath" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding UTF8
6369

64-
git switch --detach $currentHead
70+
git switch --detach $currentHead

entrypoint.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
cd "$INPUT_BUILD_ROOT_DIR"
44

55
if [ "$INPUT_VERSION" == "latest" ]; then
6-
curl -s https://api.github.com/repos/JakeWharton/dependency-tree-diff/releases/latest \
6+
curl -H "Authorization: Bearer $GITHUB_TOKEN" -s https://api.github.com/repos/JakeWharton/dependency-tree-diff/releases/latest \
77
| grep "/dependency-tree-diff.jar" \
88
| cut -d : -f 2,3 \
99
| tr -d \" \
10-
| xargs curl -L -s -o dependency-tree-diff.jar
10+
| xargs curl -H "Authorization: Bearer $GITHUB_TOKEN" -L -s -o dependency-tree-diff.jar
1111
else
12-
curl -L -s -o dependency-tree-diff.jar "https://github.com/JakeWharton/dependency-tree-diff/releases/download/$INPUT_VERSION/dependency-tree-diff.jar"
12+
curl -H "Authorization: Bearer $GITHUB_TOKEN" -L -s -o dependency-tree-diff.jar "https://github.com/JakeWharton/dependency-tree-diff/releases/download/$INPUT_VERSION/dependency-tree-diff.jar"
1313
fi
1414

1515
if [ "$INPUT_PROJECT" == ":" ]; then
@@ -20,8 +20,11 @@ if [ "$INPUT_DEBUG" == "true" ]; then
2020
echo "download finished"
2121
echo "$JAVA_HOME"
2222
java -version
23+
ls -al
2324
fi
2425

26+
chmod +x dependency-tree-diff.jar
27+
2528
current_head=$(git rev-parse HEAD)
2629

2730
./gradlew $INPUT_ADDITIONAL_GRADLE_ARGUMENTS "$INPUT_PROJECT":dependencies --configuration "$INPUT_CONFIGURATION" > dependency-tree-diff_dependencies-head.txt

testproject/gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
org.gradle.parallel=true
2+
org.gradle.caching=true
3+
org.gradle.configuration-cache=true
4+
org.gradle.configuration-cache.parallel=true

0 commit comments

Comments
 (0)