Skip to content

Commit 5ab184a

Browse files
committed
ci(gradle-api): publish only tags on main, and test on Windows
1 parent ba25f09 commit 5ab184a

1 file changed

Lines changed: 42 additions & 1 deletion

File tree

‎.github/workflows/gradle_api.yml‎

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,40 @@ jobs:
6767
working-directory: gradle-api
6868
run: ./gradlew check --console=plain
6969

70+
test-windows:
71+
name: Unit tests (Windows)
72+
runs-on: windows-latest
73+
timeout-minutes: 30
74+
75+
steps:
76+
- name: Harden the runner (Audit all outbound calls)
77+
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
78+
with:
79+
egress-policy: audit
80+
81+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
82+
with:
83+
persist-credentials: false
84+
85+
- uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
86+
with:
87+
distribution: temurin
88+
java-version: '17'
89+
90+
# The Test job validates the wrappers.
91+
- uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
92+
with:
93+
cache-provider: basic
94+
validate-wrappers: false
95+
96+
- name: Test
97+
working-directory: gradle-api
98+
run: .\gradlew.bat test --console=plain
99+
70100
publish:
71101
name: Publish to Maven Central
72102
if: startsWith(github.ref, 'refs/tags/gradle-api-v')
73-
needs: test
103+
needs: [ test, test-windows ]
74104
runs-on: ubuntu-latest
75105
timeout-minutes: 30
76106
environment: maven-central
@@ -84,6 +114,17 @@ jobs:
84114
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
85115
with:
86116
persist-credentials: false
117+
# Full history of every branch, for the main ancestry check.
118+
fetch-depth: 0
119+
120+
# A tag can point at any commit, and publishing releases it immediately.
121+
- name: Check the tagged commit is on main
122+
run: |
123+
commit="$(git rev-parse "$GITHUB_SHA^{commit}")"
124+
if ! git merge-base --is-ancestor "$commit" origin/main; then
125+
echo "::error::$GITHUB_REF_NAME points at $commit, which is not on main"
126+
exit 1
127+
fi
87128
88129
- uses: gradle/actions/wrapper-validation@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
89130
with:

0 commit comments

Comments
 (0)