-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
112 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Build, Test, and Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: "11" | ||
|
||
- name: Cache Maven dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: ${{ runner.os }}-maven | ||
|
||
- name: Increment version and build with Maven | ||
id: increment-version | ||
run: | | ||
CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | ||
echo "Current version: $CURRENT_VERSION" | ||
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F '.' '{print $1"."$2"."$3+1}') | ||
echo "New version: $NEW_VERSION" | ||
echo "artifact-version=$NEW_VERSION" >> $GITHUB_ENV | ||
- name: Build and test with Maven | ||
run: mvn clean install --batch-mode -Dartifact.version=${{ env.artifact-version }} | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build-and-test | ||
if: success() | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Upload to S3 | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
AWS_REGION: "us-east-1" | ||
run: | | ||
FILE_PATH=$(find target -name "*.jar" | head -n 1) | ||
if [ -z "$FILE_PATH" ]; then | ||
echo "Artifact not found!" && exit 1 | ||
fi | ||
S3_URI="s3://your-bucket-name/maven-repo/path/to/artifact/" | ||
aws s3 cp "$FILE_PATH" "$S3_URI" | ||
- name: Verify artifact upload | ||
run: | | ||
aws s3 ls s3://your-bucket-name/maven-repo/path/to/artifact/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters