Checkout and Create Release Version #194
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 | |
outputs: | |
version: ${{ steps.get-version.outputs.version }} | |
steps: | |
- name: check Code | |
uses: actions/checkout@v4 | |
- name: Check Version | |
id: get-version | |
run: | | |
version=$(curl -s 'https://api.github.com/repos/dataease/dataease/releases/latest' | jq -r ".tag_name") | |
echo "version=${version}" >> $GITHUB_ENV | |
echo "version=${version}" >> $GITHUB_OUTPUT | |
sed -i "s/ARG VERSION=.*/ARG VERSION=${version}/g" Dockerfile | |
echo "Current Version: ${version}" | |
- name: Check Release | |
run: | | |
echo "create=0" >> $GITHUB_ENV | |
if ! gh release view ${{ env.version }} -R ${{ github.repository }}; then | |
echo "create=1" >> $GITHUB_ENV | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Tag | |
if: env.create == '1' | |
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 | |
if: env.create == '1' | |
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: Free Disk Space (Ubuntu) | |
uses: jlumbroso/free-disk-space@main | |
with: | |
tool-cache: false | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: false | |
docker-images: false | |
swap-storage: false | |
- name: Check Version | |
run: | | |
version=${{ needs.check.outputs.version }} | |
echo "version=${version}" >> $GITHUB_ENV | |
echo "Current Version: ${version}" | |
- name: Check Release | |
run: | | |
if ! gh release view ${{ env.version }} -R ${{ github.repository }} | grep dataease-${{ env.version }}.tar.gz; then | |
echo "create=1" >> $GITHUB_ENV | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout Code | |
if: env.create == '1' | |
uses: actions/checkout@v4 | |
with: | |
repository: 'dataease/dataease' | |
ref: ${{ steps.get-version.outputs.version }} | |
lfs: true | |
- name: Set up Java | |
if: env.create == '1' | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'oracle' | |
java-version: '21' | |
cache: 'maven' | |
- name: Set up Node.js | |
if: env.create == '1' | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '16.15.0' | |
cache: 'npm' | |
cache-dependency-path: '**/package.json' | |
- name: Build Web | |
if: env.create == '1' | |
run: | | |
mvn clean install | |
cd core && mvn clean package -Pstandalone -U -Dmaven.test.skip=true | |
env: | |
dataease.version: ${{ env.version }} | |
- name: Create File | |
if: env.create == '1' | |
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 opt/dataease2.0/data/exportData opt/dataease2.0/data/plugin | |
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 | |
- name: Upload Release Asset | |
if: env.create == '1' | |
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 }} | |
- uses: docker/setup-qemu-action@v3 | |
- uses: docker/setup-buildx-action@v3 | |
- name: Get Dockerfile | |
run: | | |
wget -O Dockerfile.cicd https://github.com/wojiushixiaobai/dataease/raw/master/Dockerfile.cicd | |
- 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 | |
if: env.create == '1' | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
provenance: false | |
file: Dockerfile.cicd | |
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/riscv64,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 |