PromucFlow_constructor/.github/workflows/server.yml
Shrikant Sharat Kandula c6c128270c
Include version information when building Docker images for server and client (#2200)
* Include version information in backend builds

* Enable manual trigger of server workflow

* Add a dummy input field for manual trigger

* Fix secret checking in github actions

* Disable cron scheduling of sync job

* Build docker image on pushing a version tag

* Fix duplicated id and invalid id in release workflow

* Don't try to login to Docker

* Avoid download progress outputs from Maven

* Add version information for building client

* Calculate version number only once

* Enable push to DockerHub after building images

* Use Docker username from GitHub secrets

* Fix Docker username in tags when building image

* Use different secret for org name

* Minor refactoring in server workflow

* Update client build workflow to use version

* Enable manual triggering of client workflow

* Set snapshot version for server builds

* Push to docker for all branches (temp)

* Undo temp change to push all branches to DockerHub

* Use Docker org from secrets in client.yml

* Fix missing version reference in client.yml

* Remove debug command in dockerfile

* Save release notes in a resource file in Docker image

* Fix query serialization to get release notes

* Get releases of current repo instead of hard-coded repo

* Fix variable quoting for repo variables

* Exclude draft and prerelease nodes from image

* Fix call to any in release notes processor

* Fix syntax error in release notes script

* Implement API to get new release count and info

* Add missing ReleaseNotes component

* Have the release workflow run after a release is created

* Build server after generating release notes

* Change release trigger to "released"

* Change release trigger to "published"

* Change release trigger to released, edited and deleted

* Use JS script to get release notes, take 1

* Filter drafts and prereleases in script

* Fix syntax error in ES6

* Write release notes to file

* Create parent directory before writing release notes

* Log cwd in release notes script

* Log pwd along with release-notes content

* Handle case where working directory is incorrect

* Remove shell based release notes generator

* Don't show error when Sentry config is missing

* Check for sentry auth token to enable Sentry

* Carry build's exit code over to CI

* Mark out build result and add a note about it

* Add a small test to verify new versions computation

* Remove incorrect test assertion

* Remove generation of release notes file

* Connect to cloud services to fetch release notes data

* Fix missing runner for test class

* Handle missing cloud_services base URL

* Fix test failures due to missing mocks

* Enable sync-ee cron job

* Revert build.sh as there's no real change

* Add API to update release notes viewed version for users

* Fix prettier line-length errors

* Create UserData model for info unrelated to auth

* Fix field name calls

* Ensure we have a userId before setting userData

* Add tests for setting version number in UserData

* Include instanceId when fetching release notes
2021-01-12 18:15:15 +05:30

141 lines
5.3 KiB
YAML

# This workflow is responsible for building, testing & packaging the Java server codebase
name: Appsmith Server Workflow
on:
# This line enables manual triggering of this workflow.
workflow_dispatch:
push:
branches: [ release, master ]
# Only trigger if files have changed in this specific path
paths:
- 'app/server/**'
pull_request:
branches: [ release, master ]
paths:
- 'app/server/**'
# Change the working directory for all the jobs in this workflow
defaults:
run:
working-directory: app/server
jobs:
build:
runs-on: ubuntu-latest
# Service containers to run with this job. Required for running tests
services:
# Label used to access the service container
redis:
# Docker Hub image for Redis
image: redis
ports:
# Opens tcp port 6379 on the host and service container
- 6379:6379
steps:
# 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
# Here, the GITHUB_REF is of type /refs/head/<branch_name>. We extract branch_name from this by removing the
# first 11 characters. This can be used to build images for several branches
# Since this is an unreleased build, we get the latest released version number, increment the minor number in it,
# append a `-SNAPSHOT` at it's end to prepare the snapshot version number. This is used as the project's version.
- name: Get the version to tag the Docker image
id: vars
run: |
# Since this is an unreleased build, we set the version to incremented version number with a
# `-SNAPSHOT` suffix.
latest_released_version="$(git tag --list 'v*' --sort=-version:refname | head)"
next_version="$(echo "$latest_released_version" | awk -F. -v OFS=. '{ $NF++; print }')"
echo ::set-output name=version::$next_version-SNAPSHOT
echo ::set-output name=tag::$(echo ${GITHUB_REF:11})
# Build and test the code
- name: Build and test
env:
APPSMITH_MONGODB_URI: "mongodb://localhost:27017/mobtools"
APPSMITH_REDIS_URL: "redis://127.0.0.1:6379"
APPSMITH_ENCRYPTION_PASSWORD: "password"
APPSMITH_ENCRYPTION_SALT: "salt"
APPSMITH_IS_SELF_HOSTED: false
run: |
mvn --batch-mode versions:set \
-DnewVersion=${{ steps.vars.outputs.version }} \
-DgenerateBackupPoms=false \
-DprocessAllModules=true
mvn --batch-mode package
# Build release Docker image and push to Docker Hub
- name: Push release image to Docker Hub
if: success() && github.ref == 'refs/heads/release'
run: |
docker build --build-arg APPSMITH_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY }} -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server:${{steps.vars.outputs.tag}} .
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
# This command pushes all the tags on the machine to Docker hub. This has been written for ease of reading. Be very careful
# with this command
docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server
# Build master Docker image and push to Docker Hub
- name: Push master image to Docker Hub with commit tag
if: success() && github.ref == 'refs/heads/master'
run: |
docker build --build-arg APPSMITH_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY }} -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server:${GITHUB_SHA} .
docker build --build-arg APPSMITH_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY }} -t ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server:nightly .
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
# This command pushes all the tags on the machine to Docker hub. This has been written for ease of reading. Be very careful
# with this command
docker push ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server
# These are dummy jobs in the CI build to satisfy required status checks for merging PRs. This is a hack because Github doesn't support conditional
# required checks in monorepos. These jobs are a clone of similarly named jobs in client.yml.
#
# Check support request at: https://github.community/t/feature-request-conditional-required-checks/16761
ui-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
job: [0, 1, 2, 3, 4, 5, 6]
steps:
# Checkout the code
- uses: actions/checkout@v2
- name: Do nothing as this is a dummy step
shell: bash
run: |
exit 0
package:
runs-on: ubuntu-latest
steps:
# Checkout the code
- uses: actions/checkout@v2
- name: Do nothing as this is a dummy step
shell: bash
run: |
exit 0