Skip to content

Merge pull request #246 from lukashornych/dev #67

Merge pull request #246 from lukashornych/dev

Merge pull request #246 from lukashornych/dev #67

Workflow file for this run

# Builds and releases a new public version of evitaLab a puts it into `Releases` section of GitHub
name: Release
on:
push:
branches:
- master
concurrency:
group: ${{ github.ref_name }} # for the same branch
cancel-in-progress: true # run only one workflow at a time (cancel the previous)
permissions:
contents: read
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: Build
outputs:
released_version: ${{ steps.release_version.outputs.version }}
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Resolve new release version
id: release_version
uses: lukashornych/[email protected]
with:
prefix: 'v'
minor-identifier: '/feat(?:\\([^)]+\\))?:/'
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18.16.1'
- name: Install dependencies
run: npm install -g yarn && yarn install --frozen-lockfile
- name: Test
run: yarn test
- name: Build
env:
EVITALAB_BUILD_VERSION: ${{ steps.release_version.outputs.version }}
run: yarn build
- name: Include license in dist
run: cp LICENSE ./dist
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
release:
name: Release
needs: build
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Download built evitaLab
uses: actions/download-artifact@v4
with:
name: dist
path: ./dist/
- name: Create .zip of dist
uses: thedoctor0/[email protected]
with:
type: 'zip'
filename: 'dist.zip'
path: './dist'
- name: Create .tar.gz of dist
uses: thedoctor0/[email protected]
with:
type: 'tar'
filename: 'dist.tar.gz'
path: './dist'
- name: Create release
id: create_release
uses: release-drafter/release-drafter@v5
with:
version: ${{ needs.build.outputs.released_version }}
publish: true
- name: Upload dist.zip to release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist.zip
asset_name: Dist (zip)
asset_content_type: application/zip
- name: Upload dist.tar.gz to release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist.tar.gz
asset_name: Dist (tar.gz)
asset_content_type: application/gzip
build-docker:
name: Build Docker image
needs: [build, release]
permissions:
packages: write
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Log in to Docker hub
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
build-args: EVITALAB_BUILD_VERSION=${{ needs.build.outputs.released_version }}
context: .
file: ./Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build.outputs.released_version }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
publish-to-evitadb:
name: Publish evitaLab to evitaDB
needs: [build, release]
runs-on: ubuntu-latest
steps:
- name: Download built evitaLab
uses: actions/download-artifact@v4
with:
name: dist
path: ./dist/
- name: Clone evitaDB repository
env:
REPO: "https://x-access-token:${{ secrets.REPO_ACCESS_TOKEN }}@github.com/FgForrest/evitaDB.git"
run: |
git clone $REPO evitaDB
cd evitaDB
git remote set-url origin $REPO
- name: Copy built evitaLab to evitaDB
env:
DIST_TARGET: "evitaDB/evita_external_api/evita_external_api_lab/src/main/resources/META-INF/lab/gui/"
run: |
rm -r "$DIST_TARGET/dist"
cp -r ./dist "$DIST_TARGET/"
- name: Commit and push changes to evitaDB
env:
BRANCH_NAME: "update-evitalab-${{ needs.build.outputs.released_version }}"
run: |
cd evitaDB
git config user.name "evitaLab Bot"
git config user.email "[email protected]"
git checkout -b $BRANCH_NAME
git add .
git commit -m "build: update evitaLab to ${{ needs.build.outputs.released_version }}"
git push origin $BRANCH_NAME
- name: Create pull request with new evitaLab
uses: actions/github-script@v7
with:
github-token: '${{ secrets.REPO_ACCESS_TOKEN }}'
script: |
const branchName = 'update-evitalab-${{ needs.build.outputs.released_version }}';
const { data: pullRequest } = await github.rest.pulls.create({
owner: 'FgForrest',
repo: 'evitaDB',
title: 'Update evitaLab to ${{ needs.build.outputs.released_version }}',
head: branchName,
base: 'dev',
body: 'This PR updates embedded evitaLab with new released version.'
});
console.log('Pull request created: ', pullRequest.html_url);