PromucFlow_constructor/.github/workflows/github-release.yml
2021-02-04 09:15:56 +05:30

154 lines
5.3 KiB
YAML

name: Appsmith Github Release Workflow
# This workflow builds Docker images for server and client, and then pushes them to Docher Hub.
# The docker-tag with which this push happens in the release tag (e.g., v1.2.3 etc.).
# In addition to the above tag, unless the git-tag matches `*beta*`, we also push to the `latest` docker-tag.
# This workflow does NOT run tests.
# This workflow is automatically triggered when a relese is created on GitHub.
on:
# Ref: <https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#release>.
release:
types:
# Unlike the `released` event, the `published` event triggers for pre-releases as well.
- released
jobs:
prelude:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.get_version.outputs.tag }}
is_beta: ${{ steps.get_version.outputs.is_beta }}
steps:
- name: Environment details
run: |
echo "PWD: $PWD"
echo "GITHUB_REF: $GITHUB_REF"
echo "GITHUB_SHA: $GITHUB_SHA"
echo "GITHUB_EVENT_NAME: $GITHUB_EVENT_NAME"
- name: Get the version
id: get_version
run: |
tag="${GITHUB_REF#refs/tags/}"
echo "::set-output name=tag::$tag"
if [[ $tag == *"beta"* ]]; then
echo "::set-output name=is_beta::true"
else
echo "::set-output name=is_beta::false"
fi
build-client:
needs:
- prelude
runs-on: ubuntu-latest
defaults:
run:
working-directory: app/client
steps:
# Checkout the code
- uses: actions/checkout@v2
- name: Use Node.js 10.16.3
uses: actions/setup-node@v1
with:
node-version: "10.16.3"
# Retrieve npm dependencies from cache. After a successful run, these dependencies are cached again
- name: Cache npm dependencies
uses: actions/cache@v2
env:
cache-name: cache-yarn-dependencies
with:
# npm dependencies are stored in `~/.m2` on Linux/macOS
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
# Install all the dependencies
- name: Install dependencies
run: yarn install
- name: Create the bundle
env:
REACT_APP_ENVIRONMENT: 'PRODUCTION'
REACT_APP_FUSIONCHARTS_LICENSE_KEY: '${{ secrets.APPSMITH_FUSIONCHARTS_LICENSE_KEY }}'
REACT_APP_SEGMENT_CE_KEY: '${{ secrets.APPSMITH_SEGMENT_CE_KEY }}'
REACT_APP_VERSION_ID: '${{ needs.prelude.outputs.tag }}'
run: |
REACT_APP_VERSION_RELEASE_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')" \
yarn build
# Build Docker image and push to Docker Hub
- name: Push production image to Docker Hub with commit tag
run: |
docker build -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:${{needs.prelude.outputs.tag}} .
# Only build & tag with latest if the tag doesn't contain beta
if [[ ! ${{needs.prelude.outputs.tag}} == *"beta"* ]]; then
docker build -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:latest .
fi
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor
build-server:
needs:
- prelude
runs-on: ubuntu-latest
defaults:
run:
working-directory: app/server
steps:
- name: Checkout the code
uses: actions/checkout@v2
# Setup Java
- name: Set up JDK 1.11
uses: actions/setup-java@v1
with:
java-version: 1.11
# Retrieve maven dependencies from cache. After a successful run, these dependencies are cached again
- name: Cache maven dependencies
uses: actions/cache@v2
env:
cache-name: cache-maven-dependencies
with:
# maven dependencies are stored in `~/.m2` on Linux/macOS
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
# Build the code
- name: Build without running any tests
run: |
mvn --batch-mode versions:set \
-DnewVersion=${{ needs.prelude.outputs.tag }} \
-DgenerateBackupPoms=false \
-DprocessAllModules=true
mvn --batch-mode package -DskipTests
# Build Docker image and push to Docker Hub
- name: Push image to Docker Hub
run: |
docker build --build-arg APPSMITH_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY }} -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server:${{needs.prelude.outputs.tag}} .
# Only build & tag with latest if the tag doesn't contain beta
if [[ ! ${{needs.prelude.outputs.tag}} == *"beta"* ]]; then
docker build --build-arg APPSMITH_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY }} -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server:latest .
fi
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server