Skip to content

Commit cda479c

Browse files
committed
Create first release with github actions.
Signed-off-by: Nick Lawrence <[email protected]>
1 parent 336ba62 commit cda479c

File tree

9 files changed

+445
-21
lines changed

9 files changed

+445
-21
lines changed

.github/workflows/nlp-insights-push-validation.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: nlp-insights PUSH Validation
22
on:
33
push:
4+
branches-ignore:
5+
- 'main'
46
defaults:
57
run:
68
shell: bash

.github/workflows/prepare-release.yml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ on:
88
jobs:
99
prepare-release:
1010
name: Prepare release
11-
if: ${{ github.event.label.name != 'no-release' }}
1211
runs-on: ubuntu-latest
1312

1413
env:
15-
docker_server: docker.io
16-
docker_org: ntlawrence
14+
docker_server: quay.io
15+
docker_org: alvearie
1716
docker_repo: nlp-insights
1817

1918
steps:
@@ -37,15 +36,15 @@ jobs:
3736
if [[ "${{ github.event.label.name }}" =~ '^(release-major|release-minor|release-patch)$' ]]; then
3837
RELEASE="${{ github.event.label.name }}"
3938
elif [ -z "${{ github.event.label.name }}" ]; then
40-
&>2 echo "There was no label (valid values are release-major, release-minor, or release-patch), using release-patch"
39+
>&2 echo "There was no label (valid values are release-major, release-minor, or release-patch), using release-patch"
4140
RELEASE=release-patch
4241
else
43-
&>2 echo "The pull request must have a label in (release-major, release-minor, or release-patch)."
42+
>&2 echo "The pull request must have a label in (release-major, release-minor, or release-patch)."
4443
exit 1
4544
fi
4645
4746
echo "VERSION=$(calculate_tag ${{ env.docker_repo }} ${{ env.docker_server }} ${{ env.docker_org }} ${RELEASE} )" >> $GITHUB_ENV
48-
&>2 echo "${VERSION} was assigned as a release tag"
47+
>&2 echo "${VERSION} was assigned as a release tag"
4948
- name: Update release files
5049
run: |
5150
UPDATES=0
@@ -55,7 +54,7 @@ jobs:
5554
--docker_org=${{ env.docker_org }} \
5655
--docker_repo=${{ env.docker_repo}} || UPDATES=$?
5756
58-
&>2 echo "${UPDATES} changes were made to update the release to ${{ env.VERSION }}"
57+
>&2 echo "${UPDATES} changes were made to update the release to ${{ env.VERSION }}"
5958
6059
- name: Unit Test
6160
run: ./gradlew test
@@ -72,11 +71,27 @@ jobs:
7271

7372
- name: Push Docker Image
7473
run: |
75-
./gradlew checkSource dockerPush -PdockerUser=${{ env.docker_server }}/${{ env.docker_org }}
74+
./gradlew dockerPush -PdockerUser=${{ env.docker_server }}/${{ env.docker_org }}
7675
- name: Commit release updates to git
7776
run: |
7877
git config user.name ${{ github.actor }}
7978
git config user.email "${{ github.actor }}@users.noreply.github.com"
8079
git add -A
8180
git commit --signoff -m "Update to version ${{ env.VERSION }}" || true
8281
git push || true #Ignore errors in case no files have changed
82+
83+
# The commit that we just pushed will not trigger the prepare release action (avoids recursion)
84+
# So we need to explicitly tag the action complete for the commit that we
85+
# just pushed. This is the last step in the flow.
86+
# See: https://docs.github.com/en/rest/reference/commits#create-a-commit-status
87+
- name: Signal Completion
88+
run: |
89+
set -x
90+
BUILD_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
91+
sha=$(git rev-parse HEAD)
92+
obj="{\"state\" : \"success\", \"context\" : \"Prepare release\", \"target_url\": \"${BUILD_URL}\" }"
93+
94+
curl -X POST "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/statuses/${sha}" \
95+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
96+
-H "Accept: application/vnd.github.v3+json" \
97+
-d "${obj}"

.github/workflows/release.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ on:
33
push:
44
branches:
55
- main
6-
paths:
7-
- 'services/nlp-insights/gradle.properties'
86

97
jobs:
108
create-release:
@@ -17,7 +15,6 @@ jobs:
1715
fetch-depth: 0
1816
- name: Calculate Tag
1917
run: echo "TAG=v$(grep -oP 'version\=\K([0-9]+\.[0-9]+\.[0-9]+)' gradle.properties)" >> $GITHUB_ENV
20-
working-directory: ./services/nlp-insights
2118
- name: Create Release
2219
uses: actions/create-release@v1
2320
env:

.github/workflows/scripts/update_files_with_version.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fi
6262
######
6363
chart_yaml=${PROJECT_DIR}/chart/Chart.yaml
6464

65-
# tag
65+
# version
6666
last_service_helm_ver="$(grep "version:" ${chart_yaml} | sed -r 's/version: (.*)/\1/')"
6767
last_service_helm_ver=`echo $last_service_helm_ver | sed -e 's/^[[:space:]]*//'`
6868
if [[ ${last_service_helm_ver} != ${VERSION} ]]; then
@@ -71,6 +71,15 @@ if [[ ${last_service_helm_ver} != ${VERSION} ]]; then
7171
updates=$((updates+1))
7272
fi
7373

74+
# app version
75+
last_app_ver="$(grep "version:" ${chart_yaml} | sed -r 's/appVersion: (.*)/\1/')"
76+
last_app_ver=`echo $last_app_ver | sed -e 's/^[[:space:]]*//'`
77+
if [[ ${last_app_ver} != ${VERSION} ]]; then
78+
>&2 echo "Updating ${chart_yaml} appVersion to version ${VERSION}"
79+
sed -i -e 's/appVersion: '${last_app_ver}'/appVersion: '${VERSION}'/' ${chart_yaml}
80+
updates=$((updates+1))
81+
fi
82+
7483
## Re-package
7584
if [[ ${last_service_helm_ver} != ${VERSION} ]] || [[ ${last_tag} != ${VERSION} ]] || [[ ${last_org} != ${DOCKER_ORG} ]]; then
7685
PACKAGE="${PROJECT_DIR}/docs/charts"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
build
22
.gradle
3+
.project
4+
.pydevproject

chart/Chart.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.1.0
18+
version: 0.1.1
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
@@ -28,8 +28,8 @@ keywords:
2828
- nlp
2929
- insights
3030

31-
home: https://github.com/Alvearie/health-patterns/tree/main/services/nlp-insights
31+
home: https://github.com/LinuxForHealth/nlp-insights
3232

3333
maintainers:
34-
- name: Adam T. Clark
35-
email: atclark@us.ibm.com
34+
- name: Nicholas T. Lawrence
35+
email: ntl@us.ibm.com

chart/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
replicaCount: 1
66

77
image:
8-
repository: quay.io/alvearie/nlp-insights
8+
repository: alvearie/nlp-insights
99
pullPolicy: Always
10-
tag: 0.0.6
10+
tag: 0.1.1
1111
pullSecret:
1212

1313
service:

0 commit comments

Comments
 (0)