Merge pull request #252 from MyRobotLab/fix-init-llm #37
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
name: Build, Test, and Deploy | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build-test-deploy: | |
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" | |
distribution: "temurin" | |
- 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: | | |
BASE_VERSION="2.0" | |
BUILD_INCREMENT=1900 | |
BUILD_NUMBER=${{ github.run_number }} | |
NEW_VERSION="${BASE_VERSION}.$((BUILD_INCREMENT + BUILD_NUMBER))" | |
echo "New version: $NEW_VERSION" | |
echo "artifact-version=$NEW_VERSION" >> $GITHUB_ENV | |
- name: Build and test with Maven | |
run: mvn clean install assembly:single --batch-mode -Dartifact.version=${{ env.artifact-version }} | |
- name: Print contents of target directory | |
run: | | |
if [ ! -d "target" ]; then | |
echo "Target directory not found!" && exit 1 | |
fi | |
echo "Contents of target directory:" | |
ls -l target | |
- name: Rename artifact to include version | |
run: | | |
ZIP_FILE=$(find target -name "*.zip" | head -n 1) | |
if [ -z "$ZIP_FILE" ]; then | |
echo "Artifact not found!" && exit 1 | |
fi | |
NEW_ZIP_NAME="target/inmoov2-${{ env.artifact-version }}.zip" | |
mv "$ZIP_FILE" "$NEW_ZIP_NAME" | |
- name: Generate and upload POM file | |
run: | | |
cat > target/pom-${{ env.artifact-version }}.xml <<EOF | |
<?xml version="1.0" encoding="UTF-8"?> | |
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>fr.inmoov</groupId> | |
<artifactId>inmoov2</artifactId> | |
<version>${{ env.artifact-version }}</version> | |
<packaging>zip</packaging> | |
<description>POM was created from install:install-file</description> | |
</project> | |
EOF | |
- name: Generate and upload maven-metadata.xml file | |
run: | | |
TIMESTAMP=$(date +"%Y%m%d%H%M%S") | |
cat > target/maven-metadata.xml <<EOF | |
<?xml version="1.0" encoding="UTF-8"?> | |
<metadata> | |
<groupId>fr.inmoov</groupId> | |
<artifactId>inmoov2</artifactId> | |
<versioning> | |
<release>${{ env.artifact-version }}</release> | |
<versions> | |
<version>${{ env.artifact-version }}</version> | |
</versions> | |
<lastUpdated>$TIMESTAMP</lastUpdated> | |
</versioning> | |
</metadata> | |
EOF | |
- 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" | |
# s3://myrobotlab-repo/artifactory/myrobotlab/fr/inmoov/inmoov2/2.0.1897/inmoov2-2.0.1897.zip | |
run: | | |
S3_METADATA_URI="s3://myrobotlab-repo/artifactory/myrobotlab/fr/inmoov/inmoov2/maven-metadata.xml" | |
aws s3 cp "target/maven-metadata.xml" "$S3_METADATA_URI" | |
S3_POM_URI="s3://myrobotlab-repo/artifactory/myrobotlab/fr/inmoov/inmoov2/${{ env.artifact-version }}/inmoov2-${{ env.artifact-version }}.pom" | |
aws s3 cp "target/pom-${{ env.artifact-version }}.xml" "$S3_POM_URI" | |
S3_URI="s3://myrobotlab-repo/artifactory/myrobotlab/fr/inmoov/inmoov2/${{ env.artifact-version }}/inmoov2-${{ env.artifact-version }}.zip" | |
aws s3 cp "target/inmoov2-${{ env.artifact-version }}.zip" "$S3_URI" | |
# - name: Verify artifact upload | |
# run: | | |
# aws s3 ls "s3://myrobotlab-repo/artifactory/myrobotlab/fr/inmoov/inmoov2/${{ env.artifact-version }}" | |
- name: Create Git tag for version | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
if git tag -l | grep -q "v${{ env.artifact-version }}"; then | |
echo "Tag v${{ env.artifact-version }} already exists. Skipping tag creation." | |
else | |
git config user.name "github-actions" | |
git config user.email "github-actions@github.com" | |
git tag -a "v${{ env.artifact-version }}" -m "Release version ${{ env.artifact-version }}" | |
git push origin "v${{ env.artifact-version }}" | |
fi |