Skip to content

Commit 891d796

Browse files
authored
Remove version from build logic (#8)
JitPack will pass `-Pversion` and version doesn't matter for javadoc. Removes the need of "prepare for next version" commits. Also, dry run GitHub actions on PRs as a limited form of testing.
1 parent a5cf5c8 commit 891d796

File tree

4 files changed

+39
-20
lines changed

4 files changed

+39
-20
lines changed

.github/workflows/check-new-api-spec.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
name: 'Check for new API spec version'
22

33
on:
4-
workflow_dispatch:
54
schedule:
65
- cron: '0 6 * * 1'
6+
workflow_dispatch:
7+
inputs:
8+
dry_run:
9+
description: 'Dry run'
10+
type: boolean
11+
required: false
12+
workflow_call:
713

814
defaults:
915
run:
1016
shell: bash
1117

18+
env:
19+
DRY_RUN: ${{ github.event.inputs.dry_run || github.event_name == 'pull_request' }}
20+
1221
jobs:
1322

1423
check-new-api-spec:
@@ -24,6 +33,7 @@ jobs:
2433
[[ -n "$version" ]]
2534
echo "SPEC_VERSION=$version" | tee -a "$GITHUB_ENV"
2635
- name: 'Create PR'
36+
if: ${{ env.DRY_RUN == 'false' }}
2737
uses: peter-evans/create-pull-request@v4
2838
with:
2939
branch: "feature/api-spec-${{ env.SPEC_VERSION }}"

.github/workflows/pr.yml

+6
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,9 @@ jobs:
4444
- name: 'unittest discover'
4545
if: ${{ steps.diff.outputs.all_modified_files }}
4646
run: python3 -m unittest discover -bs .github/scripts
47+
48+
publish-javadoc-dry-run:
49+
uses: ./.github/workflows/publish-javadoc.yml
50+
51+
check-new-api-spec-dry-run:
52+
uses: ./.github/workflows/check-new-api-spec.yml

.github/workflows/publish-javadoc.yml

+21-18
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,55 @@ on:
55
tags: ['*']
66
workflow_dispatch:
77
inputs:
8-
version_name:
9-
description: 'Version'
10-
required: true
8+
dry_run:
9+
description: 'Dry run'
10+
type: boolean
11+
required: false
12+
workflow_call:
1113

1214
defaults:
1315
run:
1416
shell: bash
1517

1618
env:
17-
VERSION_NAME: ${{ github.event.inputs.version_name || github.ref_name }}
19+
DRY_RUN: ${{ github.event.inputs.dry_run || github.event_name == 'pull_request' }}
20+
JAR_NAME: gradle-enterprise-api-kotlin-SNAPSHOT-javadoc.jar
1821

1922
jobs:
2023

2124
build-javadoc:
2225
runs-on: ubuntu-latest
23-
outputs:
24-
version: ${{ env.VERSION }}
2526
steps:
2627
- name: Checkout
2728
uses: actions/checkout@v3
28-
with:
29-
ref: ${{ env.VERSION_NAME }}
3029
- name: Build javadoc
3130
uses: ./.github/actions/build
3231
with:
3332
tasks: 'javadocJar'
3433
artifact-name: 'javadoc'
35-
path-to-upload: "build/libs/gradle-enterprise-api-kotlin-${{ env.VERSION_NAME }}-javadoc.jar"
34+
path-to-upload: "build/libs/${{ env.JAR_NAME }}"
3635

37-
commit-to-gh-pages:
36+
publish-javadoc:
3837
needs: [build-javadoc]
3938
runs-on: ubuntu-latest
4039
steps:
4140
- name: Checkout
4241
uses: actions/checkout@v3
43-
with:
44-
ref: ${{ env.VERSION_NAME }}
42+
- name: Fetch branch
43+
run: git fetch origin gh-pages && git checkout FETCH_HEAD
4544
- name: Download javadoc
4645
uses: actions/download-artifact@v3
47-
- name: Commit and push
46+
- name: Unzip javadoc
47+
run: rm -rf docs && unzip "javadoc/$JAR_NAME" -d docs
48+
- name: Commit
4849
run: |
4950
git config user.name github-actions
5051
git config user.email github-actions@github.com
51-
git checkout gh-pages
52-
rm -rf docs
53-
unzip "gradle-enterprise-api-kotlin-$VERSION_NAME-javadoc.jar" -d docs
5452
git add docs
55-
git commit -m "Add $VERSION_NAME javadoc"
56-
git push
53+
git commit -m "Add ${{ github.ref_name }} javadoc"
54+
- name: Push
55+
run: |
56+
if [[ "$DRY_RUN" == 'true' ]]; then
57+
args=' --dry-run'
58+
fi
59+
git push origin HEAD:gh-pages $args

build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ plugins {
1111
}
1212

1313
group = "com.github.gabrielfeo"
14-
version = "0.10.0"
14+
version = "SNAPSHOT"
1515
val repoUrl = "https://github.com/gabrielfeo/gradle-enterprise-api-kotlin"
1616

1717
val downloadApiSpec by tasks.registering {

0 commit comments

Comments
 (0)