feat: add actions #8
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
on: | |
push: | |
branches: | |
- master | |
schedule: | |
- cron: '0 1 * * *' | |
name: Checkout and Create Release Version | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: check Code | |
uses: actions/checkout@v4 | |
- name: Check Version | |
run: | | |
version=$(curl -s 'https://api.github.com/repos/dataease/dataease/releases/latest' | jq -r ".tag_name") | |
echo "version=${version}" >> $GITHUB_ENV | |
- name: Check Release | |
run: | | |
if gh release view ${{ env.version }} -R ${{ github.repository }} | grep dataease-${{ env.version }}.tar.gz; then | |
echo "Release already exists" | |
exit 1 | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Tag | |
run: | | |
git config --global user.name "${GITHUB_ACTOR}" | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git tag -a ${{ env.version }} -m "Release ${{ env.version }}" | |
git push origin ${{ env.version }} || echo "Tag already exists" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Release | |
run: | | |
gh release create ${{ env.version }} -R ${{ github.repository }} --title "Release ${{ env.version }}" --notes "Release ${{ env.version }}" || echo "Release already exists" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build: | |
needs: check | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check Version | |
run: | | |
version=$(curl -s 'https://api.github.com/repos/dataease/dataease/releases/latest' | jq -r ".tag_name") | |
echo "version=${version}" >> $GITHUB_ENV | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
repository: 'dataease/dataease' | |
ref: ${{ steps.get-version.outputs.version }} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: 'maven' | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '16.15.0' | |
- name: Build Web | |
run: | | |
mvn clean install | |
cd core && mvn clean package -Pstandalone -U -Dmaven.test.skip=true | |
- name: Create File | |
run: | | |
mkdir -p opt/apps opt/dataease2.0/drivers opt/dataease2.0/cache opt/dataease2.0/data/map opt/dataease2.0/data/static-resource opt/dataease2.0/data/appearance | |
cp -rf drivers/* opt/dataease2.0/drivers/ | |
cp -rf mapFiles/* opt/dataease2.0/data/map/ | |
cp -rf staticResource/* opt/dataease2.0/data/static-resource/ | |
cp -f core/core-backend/target/CoreApplication.jar opt/apps/app.jar | |
mv opt dataease-${{ env.version }} | |
tar -czf dataease-${{ env.version }}.tar.gz dataease-${{ env.version }} | |
sha256sum dataease-${{ env.version }}.tar.gz > dataease-${{ env.version }}.tar.gz.sha256 | |
- uses: docker/setup-qemu-action@v3 | |
- uses: docker/setup-buildx-action@v3 | |
- name: Get Dockerfile | |
run: | | |
wget -O Dockerfile.release https://github.com/wojiushixiaobai/dataease/raw/master/Dockerfile | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and Push Image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
provenance: false | |
file: Dockerfile.release | |
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x | |
push: true | |
tags: | | |
${{ github.repository_owner }}/dataease:${{ env.version }} | |
${{ github.repository_owner }}/dataease:latest | |
ghcr.io/${{ github.repository_owner }}/dataease:${{ env.version }} | |
ghcr.io/${{ github.repository_owner }}/dataease:latest | |
outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Upload Release Asset | |
run: | | |
gh release upload ${{ env.version }} dataease-${{ env.version }}.tar.gz dataease-${{ env.version }}.tar.gz.sha256 -R ${{ github.repository }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |