forked from lucee/extension-hibernate
-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (143 loc) · 5.79 KB
/
ci.yml
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Main Build
on:
# If you push to master|main this will trigger a stable release. Else, a snapshot.
push:
branches:
- master
- main
- development
- release/**
workflow_dispatch:
# Reusable workflow : Usually called by a `snapshot` workflow
workflow_call:
env:
SNAPSHOT: ${{ github.ref_name != 'main' && github.ref_name != 'master' }}
PROJECT_NAME: Ortus Lucee Extensions - ORM
EXTENSION_SLUG: ortus-orm-extension
AWS_BUCKETNAME: downloads.ortussolutions.com
ARTIFACTS_DIRECTORY: artifacts
jobs:
security:
uses: ./.github/workflows/security.yml
secrets: inherit
tests:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
uses: ./.github/workflows/tests.yml
format:
if: "!contains(github.event.head_commit.message, '[ci skip]') && github.ref_name != 'main' && github.ref_name != 'master'"
uses: ./.github/workflows/format.yml
release:
runs-on: ubuntu-latest
needs: [ tests ]
if: "!contains(github.event.head_commit.message, '[ci skip]')"
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
- name: Read version
id: current_version
run: |
export PACKAGE_VERSION=$( cat box.json | jq '.version' -r )
echo "EXTENSION_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
echo "BRANCH=master" >> $GITHUB_ENV
echo "BUILD_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
if [ $SNAPSHOT == 'true' ]
then
echo "BUILD_VERSION=$PACKAGE_VERSION.${{ github.run_number}}-snapshot" >> $GITHUB_ENV
fi
- name: Check changelog for this version
if: env.SNAPSHOT == 'false'
id: changelog_check
run: |
if grep -q "${{ env.EXTENSION_VERSION }}" CHANGELOG.md;then
echo "HAS_VERSION=true" >> $GITHUB_OUTPUT
else
echo "HAS_VERSION=false" >> $GITHUB_OUTPUT
fi
- name: Update changelog [unreleased] with latest version
uses: thomaseizinger/[email protected]
if: "steps.changelog_check.outputs.HAS_VERSION == 'false' && env.SNAPSHOT == 'false'"
with:
changelogPath: ./CHANGELOG.md
tag: ${{ env.EXTENSION_VERSION }}
- name: Commit Changelog
uses: EndBug/[email protected]
if: "steps.changelog_check.outputs.HAS_VERSION == 'false' && env.SNAPSHOT == 'false'"
with:
author_name: Github Actions
author_email: [email protected]
message: '📖 DOC: Finalized changelog for v${{ env.EXTENSION_VERSION }} - [ci skip]'
add: CHANGELOG.md
- name: Set temporary (snapshot) version in pom.xml
if: env.SNAPSHOT == 'true'
run: sed -i -e "s/${{ env.EXTENSION_VERSION }}/${{ env.BUILD_VERSION }}/g" pom.xml
- name: Generate Javadocs
if: env.SNAPSHOT == 'false'
run: mvn --batch-mode -f pom.xml javadoc:javadoc
- name: Upload API Docs to S3
uses: jakejarvis/s3-sync-action@master
if: env.SNAPSHOT == 'false'
with:
args: --acl public-read
env:
AWS_S3_BUCKET: ${{ secrets.AWS_APIDOCS_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_SECRET }}
SOURCE_DIR: "target/apidocs"
DEST_DIR: "lucee/hibernate-extension/${{ env.BUILD_VERSION }}/"
- name: Build with Maven
run: mvn --batch-mode -f pom.xml package
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ortus_orm_${{ env.BUILD_VERSION }}.lex
path: target/*.lex
- run: |
mkdir .tmp/
mv target/*.lex .tmp/
- name: Upload Artifact to S3
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read
env:
AWS_S3_BUCKET: ${{ secrets.AWS_DOWNLOADS_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_SECRET }}
SOURCE_DIR: ".tmp/"
DEST_DIR: "ortussolutions/lucee-extensions/ortus-orm/${{ env.BUILD_VERSION }}/"
- name: Setup CommandBox
uses: Ortus-Solutions/setup-commandbox@main
with:
forgeboxAPIKey: ${{ secrets.FORGEBOX_API_TOKEN }}
- run: |
box package set version=${{ env.BUILD_VERSION }}
box package set location="https://s3.amazonaws.com/${{ env.AWS_BUCKETNAME }}/ortussolutions/lucee-extensions/ortus-orm/${{ env.BUILD_VERSION }}/ortus_orm_${{ env.BUILD_VERSION }}.lex"
box publish
- name: Tag Version
uses: rickstaa/[email protected]
if: env.SNAPSHOT == 'false'
with:
tag: "v${{ env.BUILD_VERSION }}"
force_push_tag: true
tag_exists_error: false
message: "Release v${{ env.BUILD_VERSION }}"
- name: Check whether a Slack Webhook is Configured
id: webhook_configured
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
echo "HAS_WEBHOOK=${{ env.WEBHOOK_URL != '' }}" >> $GITHUB_OUTPUT
- name: Inform Slack
if: ${{ steps.webhook_configured.outputs.HAS_WEBHOOK == 'true' && failure() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: ortus-hibernate-extension
SLACK_COLOR: ${{ job.status }} # or a specific color like 'green' or '#ff00ff'
SLACK_ICON_EMOJI: ":bell:"
SLACK_MESSAGE: '${{ env.EXTENSION_SLUG }} v${{ env.BUILD_VERSION }} ( ${{ github.ref_name }} ) failed :cry:'
SLACK_TITLE: "${{ env.PACKAGE_NAME }} Build"
SLACK_USERNAME: CI
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}