Skip to content

Commit

Permalink
ci: adding concourse ci (#4)
Browse files Browse the repository at this point in the history
* ci: adding concourse ci

* chore: linux EOL

* chore: adding repipe script

* chore: updated values

* fix: dockerfile

* chore: changes in dockerfile and build job

* chore: updated values

* dummy commit

* c: changes in build script

* chore: adding chmod +x

* chore: update dockerFile

* ci: check user

* ci: install gcloud differently

* ci: make tasks executable

* ci: fix script invocation

* fix: gcloud?

* bump to 0.1.0

* bump to 0.1.1

* bump to 0.1.2

* bump to 0.1.3

* bump to 0.1.4

* bump to 0.1.5

* bump to 0.1.6

* bump to 0.1.7

* bump to 0.1.8

* bump to 0.1.9

* bump to 0.1.10

* bump to 0.1.11

* ci: changes in pipeline config

* ci: update branch

* bump to 0.1.12

* bump to 0.1.13

* bump to 0.1.14

* core: update pipeline to include apk

* chore: removed git-cliff

---------

Co-authored-by: Kartik Shah <[email protected]>
Co-authored-by: git <git@localhost>
  • Loading branch information
3 people authored Mar 28, 2024
1 parent 4c30645 commit af4df08
Show file tree
Hide file tree
Showing 12 changed files with 424 additions and 1 deletion.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions ci/config/git-cliff-release.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# configuration file for git-cliff (0.1.0)

[changelog]
# changelog header
header = """"""

# template for the changelog body
# https://tera.netlify.app/docs/#introduction
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }} (by {{ commit.author.name }})\
{% endfor %}
{% endfor %}\n
"""
# remove the leading and trailing whitespaces from the template
trim = true
# changelog footer
footer = """"""

[git]
# parse the commits based on https://www.conventionalcommits.org
conventional_commits = true
# filter out the commits that are not conventional
filter_unconventional = true
# regex for parsing and grouping commits
commit_parsers = [
{ message = "^feat", group = "Features"},
{ message = "^fix", group = "Bug Fixes"},
]
# filter out the commits that are not matched by commit parsers
filter_commits = true
# glob pattern for matching git tags
tag_pattern = "v[0-9]*"
# regex for skipping tags
skip_tags = "v0.1.0-beta.1"
# regex for ignoring tags
ignore_tags = ""
# sort the tags topologically
topo_order = false
# sort the commits inside sections by oldest/newest order
sort_commits = "newest"
58 changes: 58 additions & 0 deletions ci/image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
FROM --platform=linux/amd64 ubuntu:24.04

# set environment variables for android SDK
ENV ANDROID_SDK_TOOLS_VERSION=11076708
ENV ANDROID_SDK_TOOLS_CHECKSUM=2d2d50857e4eb553af5a6dc3ad507a17adf43d115264b1afc116f95c92e5e258
ENV ANDROID_HOME="/opt/android-sdk-linux"
ENV ANDROID_SDK_ROOT=$ANDROID_HOME
ENV PATH=$PATH:$ANDROID_HOME/cmdline-tools:$ANDROID_HOME/cmdline-tools/bin:$ANDROID_HOME/platform-tools

# set environment variable for gradle
ENV GRADLE_VERSION=8.3

ENV DEBIAN_FRONTEND=noninteractive
ENV LANG=en_US.UTF-8
ENV GH_CLI_VERSION=2.23.0
ENV GHTOKEN_VERSION=2.0.1
ENV HOME=/home/mobiledevops

# basic setup and dependencies installation
RUN apt-get -qq update && \
apt-get -qqy --no-install-recommends install apt-utils build-essential openjdk-17-jdk openjdk-17-jre-headless software-properties-common libssl-dev libffi-dev python3-dev cargo pkg-config libstdc++6 libpulse0 libglu1-mesa openssh-server zip unzip curl lldb git wget > /dev/null && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# install Android SDK
RUN curl -s https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS_VERSION}_latest.zip > /tools.zip && \
echo "${ANDROID_SDK_TOOLS_CHECKSUM} /tools.zip" | sha256sum -c && \
unzip -qq /tools.zip -d $ANDROID_HOME && \
rm -v /tools.zip && \
mkdir -p $ANDROID_HOME/licenses/ && \
echo -e "8933bad161af4178b1185d1a37fbf41ea5269c55\nd56f5187479451eabf01fb78af6dfcb131a6481e\n24333f8a63b6825ea9c5514f83c2829b004d1fee" > $ANDROID_HOME/licenses/android-sdk-license && \
echo -e "84831b9409646a918e30573bab4c9c91346d8abd\n504667f4c0de7af1a06de9f4b1727b84351f2910" > $ANDROID_HOME/licenses/android-sdk-preview-license --licenses && \
yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --licenses --sdk_root=${ANDROID_SDK_ROOT}

# setup work directory
WORKDIR $HOME/app

# install SDKMAN and Gradle
RUN curl -s "https://get.sdkman.io" | bash && \
bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && sdk install gradle ${GRADLE_VERSION}"

# install Google Cloud SDK
RUN curl -sSL https://sdk.cloud.google.com | bash
ENV PATH $PATH:$HOME/google-cloud-sdk/bin

# install gh-token
RUN wget -O ghtoken https://github.com/Link-/gh-token/releases/download/v${GHTOKEN_VERSION}/linux-amd64 && \
echo "f76e8cb35f0b04b59073a486cc952e50fa9f1c930a25619ea9abcf44a13165c4 ghtoken" | shasum -c - && \
chmod u+x ./ghtoken && \
mv ./ghtoken /usr/local/bin/ghtoken

# install GitHub CLI
RUN mkdir ghcli && cd ghcli && \
wget https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_386.tar.gz -O ghcli.tar.gz && \
tar --strip-components=1 -xf ghcli.tar.gz && \
mv bin/gh /usr/local/bin && cd ../ && rm -rf ./ghcli

# reset work directory
WORKDIR $HOME/app
188 changes: 188 additions & 0 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
#@ load("@ytt:data", "data")

#@ def pipeline_image():
#@ return data.values.docker_registry + "/pos-print-companion"
#@ end

#@ def release_pipeline_image():
#@ return data.values.docker_registry + "/release-pipeline"
#@ end

#@ def task_image_config():
type: registry-image
source:
username: #@ data.values.docker_registry_user
password: #@ data.values.docker_registry_password
repository: #@ pipeline_image()
#@ end

#@ def release_task_image_config():
type: registry-image
source:
username: #@ data.values.docker_registry_user
password: #@ data.values.docker_registry_password
repository: #@ release_pipeline_image()
#@ end

resource_types:
- name: gcs-resource
type: docker-image
source:
repository: frodenas/gcs-resource

resources:
- name: repo
type: git
webhook_token: ((webhook.secret))
source:
uri: #@ data.values.git_uri
branch: #@ data.values.git_branch
private_key: #@ data.values.github_private_key
- name: pipeline-tasks
type: git
source:
paths: [ "ci/*" ]
uri: #@ data.values.git_uri
branch: #@ data.values.pipeline_git_branch
private_key: #@ data.values.github_private_key
- name: pipeline-image-def
type: git
source:
paths: [ci/image/Dockerfile]
uri: #@ data.values.git_uri
branch: #@ data.values.pipeline_git_branch
private_key: #@ data.values.github_private_key
- name: gh-release
type: github-release
source:
owner: #@ data.values.gh_org
repository: #@ data.values.gh_repository
access_token: #@ data.values.github_api_token
release: true
- name: built-dev-apk
type: gcs-resource
source:
bucket: #@ data.values.build_artifacts_bucket_name
json_key: #@ data.values.build_artifacts_bucket_creds
regexp: pos-print-companion/dev/android/pos-print-companion-(.+)-v.+/apk/release/app-release-unsigned.apk
- name: version
type: semver
source:
initial_version: 0.0.0
driver: git
file: version
uri: #@ data.values.git_uri
branch: #@ data.values.git_version_branch
private_key: #@ data.values.github_private_key
- name: pipeline-image
type: registry-image
source:
tag: latest
username: #@ data.values.docker_registry_user
password: #@ data.values.docker_registry_password
repository: #@ pipeline_image()

groups:
- name: pos-companion
jobs:
- build
- release
- name: image
jobs:
- build-pipeline-image

jobs:
- name: build-pipeline-image
serial: true
plan:
- get: pipeline-image-def
trigger: true
- task: build
privileged: true
config:
platform: linux
image_resource:
type: registry-image
source:
repository: vito/oci-build-task
inputs:
- name: pipeline-image-def
outputs:
- name: image
params:
CONTEXT: pipeline-image-def/ci/image
run:
path: build
- put: pipeline-image
params:
image: image/image.tar

- name: build
serial: true
plan:
- in_parallel:
- { get: repo, trigger: true }
- get: pipeline-tasks
- task: build
config:
platform: linux
image_resource: #@ task_image_config()
inputs:
- name: repo
- name: pipeline-tasks
outputs:
- name: repo
- name: artifacts
run:
path: pipeline-tasks/ci/tasks/build.sh

- task: upload-to-gcs
config:
platform: linux
image_resource: #@ task_image_config()
inputs:
- name: repo
- name: artifacts
- name: pipeline-tasks
run:
path: pipeline-tasks/ci/tasks/upload-to-gcs.sh
params:
VERSION_FILE: repo/.git/ref
GCS_DIRECTORY: dev
bucket: #@ data.values.build_artifacts_bucket_name
json_key: #@ data.values.build_artifacts_bucket_creds

- name: release
serial: true
plan:
- in_parallel:
- get: repo
trigger: true
passed: [ build ]
- get: pipeline-tasks
- get: version
- get: built-dev-apk
- task: prep-release
config:
platform: linux
image_resource: #@ release_task_image_config()
inputs:
- name: repo
- name: pipeline-tasks
- name: version
outputs:
- name: version
- name: artifacts
run:
path: pipeline-tasks/ci/tasks/prep-release-src.sh
- in_parallel:
- put: gh-release
params:
name: artifacts/gh-release-name
tag: artifacts/gh-release-tag
body: artifacts/gh-release-notes.md
globs:
- built-dev-apk/app-release-unsigned.apk
- put: version
params:
file: version/version
22 changes: 22 additions & 0 deletions ci/repipe
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e

if [[ $(which ytt) == "" ]]; then
echo "You will need to install ytt to repipe. https://carvel.dev/ytt/"
exit 1
fi

target="${FLY_TARGET:-galoy}"
team=dev

TMPDIR=""
TMPDIR=$(mktemp -d -t repipe.XXXXXX)
trap "rm -rf ${TMPDIR}" INT TERM QUIT EXIT

ytt -f ci > ${TMPDIR}/pipeline.yml

echo "Updating pipeline @ ${target}"

fly -t ${target} set-pipeline --team=${team} -p pos-print-companion -c ${TMPDIR}/pipeline.yml
fly -t ${target} unpause-pipeline --team=${team} -p pos-print-companion
11 changes: 11 additions & 0 deletions ci/tasks/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -eu

current_dir=$(pwd)
cd repo/
./gradlew build
cd "$current_dir"

mkdir -p artifacts/app/build/outputs/apk
cp -r repo/app/build/outputs/apk/* artifacts/app/build/outputs/apk
Loading

0 comments on commit af4df08

Please sign in to comment.