Skip to content

Commit

Permalink
add automatic github actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
t1anyuv committed Jan 14, 2025
1 parent 97c8a76 commit 2965848
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
37 changes: 37 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Maven Build and Deploy

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adoptopenjdk'

- name: Cache Maven dependencies
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/*.java') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up Maven settings
run: |
mkdir -p ~/.m2
echo '<settings><servers><server><id>github</id><username>${{ secrets.MY_GITHUB_USERNAME }}</username><password>${{ secrets.GITHUBPACKAGE_TOKEN }}</password></server></servers></settings>' > ~/.m2/settings.xml
- name: Build and deploy to GitHub Packages
run: |
mvn clean deploy -DskipTests # 如果不需要跳过测试,删除 -DskipTests
9 changes: 9 additions & 0 deletions .github/workflows/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<settings>
<servers>
<server>
<id>github</id>
<username>YOUR_GITHUB_USERNAME</username>
<password>${env.MY_GITHUB_TOKEN}</password> <!-- 使用 GitHub Actions 环境变量 -->
</server>
</servers>
</settings>
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
target/
.idea
dependency-reduced-pom.xml
dependency-reduced-pom.xml
/.github/
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,12 @@
</plugin>
</plugins>
</build>

<distributionManagement>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/Spatio-Temporal-Lab/start-shaded-avatica-core</url>
</repository>
</distributionManagement>

</project>

0 comments on commit 2965848

Please sign in to comment.