-
-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (68 loc) · 2.28 KB
/
Copy pathbuild.yml
File metadata and controls
68 lines (68 loc) · 2.28 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
name: Build in CI
on:
workflow_dispatch:
push:
paths-ignore:
- '**/.md'
pull_request:
paths-ignore:
- '**/.md'
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
name: Build and Test
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
- name: Setup Java
uses: actions/setup-java@v5.2.0
with:
java-version: '21'
distribution: adopt
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6.1.0
- name: Build
run: ./gradlew check --info
shell: bash
- name: Release (if required)
id: get-version
if: github.ref == 'refs/heads/main'
run: |-
git config user.name github-actions
git config user.email github-actions@github.com
git remote set-url origin https://x-access-token:$GH_TOKEN@github.com/http4k/standards.git
LOCAL_VERSION=$(jq -r .http4k.version version.json)
git fetch --deepen=1 || true
if git rev-parse HEAD~1 >/dev/null 2>&1; then
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
else
CHANGED_FILES=$(git show --name-only --pretty=format: HEAD)
fi
if [[ "$CHANGED_FILES" != *version.json* ]]; then
echo "Version did not change on this commit. Ignoring"
echo "tag-created=false" >> $GITHUB_OUTPUT
exit 0
fi
git tag -a "$LOCAL_VERSION" -m "Typeflows JVM version $LOCAL_VERSION"
git push origin "$LOCAL_VERSION"
# Output tag for repository dispatch
echo "tag=$LOCAL_VERSION" >> $GITHUB_OUTPUT
echo "tag-created=true" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.TOOLBOX_REPO_TOKEN }}
shell: bash
- name: Repository Dispatch
if: (github.ref == 'refs/heads/main' && steps.get-version.outputs.tag-created == 'true')
run: |-
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/dispatches \
-d '{"event_type":"release","client_payload":{"tag":"${{ steps.get-version.outputs.tag }}"}}'
env:
GH_TOKEN: ${{ secrets.TOOLBOX_REPO_TOKEN }}
shell: bash