Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/scripts/check-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

VERSION=$(cat -s "VERSION" 2>/dev/null)
MAIN_VERSION=$(curl -s "https://raw.githubusercontent.com/TheWorldAvatar/viz/main/VERSION")

if [ "$VERSION" == "" ]; then
echo -e "\e[31mError\e[0m: VERSION file is empty. Please ensure the correct version number is written here. Version currently on main is: $MAIN_VERSION"
exit 1
fi
echo "Version set in this PR: $VERSION"
echo "Version on main: $MAIN_VERSION"

# Get the VERSION file from the main branch of the repo, check that this new version is updated ie does not match
if [ "$VERSION" == "$MAIN_VERSION" ]; then
echo -e "\e[31mError\e[0m: VERSION specified on this branch matches that on main. Update the VERSION file before merging."
exit 1
fi

# Check that there's no -SNAPSHOT qualifier
TOKEN="-SNAPSHOT"
if [[ "$VERSION" == *"$TOKEN"* ]]; then
echo -e "\e[31mError\e[0m: Remove the \"-SNAPSHOT\" qualifier in VERSION"
exit 1
fi

# Check that the change log contains an entry for the updated versions
CHANGELOG="CHANGELOG.md"
TOKEN="# $VERSION"
if ! grep -q "$TOKEN" "$CHANGELOG"; then
echo -e "\e[31mError\e[0m: Could not find corresponding entry for release $VERSION in CHANGELOG.md"
exit 1
fi

# Update version in code/pom.xml
POM_XML="code/pom.xml"
if [ -f "$POM_XML" ]; then
sed -i -E "s|<version>[0-9]+\.[0-9]+\.[0-9]+</version>|<version>$VERSION</version>|" "$POM_XML"
echo "Updated version in $POM_XML to $VERSION"
else
echo -e "\e[31mError\e[0m: $POM_XML not found"
exit 1
fi
Comment on lines +34 to +42
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be removed if we make use of the mvnw script(s) to read the version number from the VERSION file and then append -Drevision=$VERSION onto the mvn calls.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay cool I didn't actually look at your credo agent handling of this yet is that what you used there?


# Update image version in docker-compose.yml
DOCKER_COMPOSE="docker-compose.yml"
if [ -f "$DOCKER_COMPOSE" ]; then
sed -i.bak -E "s|(image: .+:).+|\1$VERSION|" "$DOCKER_COMPOSE" && rm "$DOCKER_COMPOSE.bak"
echo "Updated image version in $DOCKER_COMPOSE to $VERSION"
else
echo -e "\e[31mError\e[0m: $DOCKER_COMPOSE not found"
exit 1
fi
Comment on lines +44 to +52
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this would be handled using a variable in the Docker compose file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah probably better alright. I was thinking it was nice to see the changed file in PRs but probably pointless if compose file never changes otherwise


echo -e "\e[32mVersion incremented\e[0m, pom.xml and docker-compose.yml updated. Next step in this action will commit the changes"

exit 0
29 changes: 0 additions & 29 deletions .github/scripts/fia/make-release-body.sh

This file was deleted.

57 changes: 0 additions & 57 deletions .github/scripts/fia/make-release-email.py

This file was deleted.

48 changes: 0 additions & 48 deletions .github/scripts/set-maven-credentials.sh

This file was deleted.

52 changes: 52 additions & 0 deletions .github/workflows/check-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Check Version

on:
pull_request:
branches:
- main
paths:
- code/**

jobs:
check-version:
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Check out repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Set up Git
run: |
git config --global user.email "viz-bot@noreply.theworldavatar.io"
git config --global user.name "twa-viz-bot"

- name: Check version incrementation
run: |
chmod +x .github/scripts/check-version.sh
.github/scripts/check-version.sh

- name: Save version to environment
run: echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV

- name: Check for changes
id: changes
run: |
git checkout ${{ github.head_ref }}
git add code/package.json docker-compose.yml
if ! git diff-index --quiet HEAD --; then
echo "::set-output name=changes::changes"
fi

- name: Push auto incremented version changes
if: steps.changes.outputs.changes == 'changes'
run: |
git commit -m "Update version to $VERSION in package.json and docker-compose.yml"
git push origin ${{ github.head_ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51 changes: 51 additions & 0 deletions .github/workflows/docker-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Docker Image CI

on:
push:
branches:
- main
paths:
- code/**
workflow_dispatch:

jobs:
build-and-push-image:
runs-on: ubuntu-latest

permissions:
packages: write

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set version variables from file
id: read-version
run: |
VERSION=$(cat VERSION)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "MAJOR=$(echo $VERSION | cut -d. -f1)" >> $GITHUB_ENV
echo "MINOR=$(echo $VERSION | cut -d. -f1).$(echo $VERSION | cut -d. -f2)" >> $GITHUB_ENV

# Set up Maven settings with GitHub token (currently needs one with access to packages on the old org. Will be replaced with the regular token when everything in same org)
- name: Set up Maven settings
run: |
mkdir -p ~/.m2
echo "<settings><servers><server><id>github</id><username>${{ secrets.USHCODE_USERNAME }}</username><password>${{ secrets.USHCODE_PACKAGE_TOKEN }}</password></server></servers></settings>" > ~/.m2/settings.xml

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Docker Image CI' step
Uses Step
uses 'docker/login-action' with ref 'v3', not a pinned commit hash
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build docker image and push to ghcr
uses: docker/build-push-action@v6

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Docker Image CI' step
Uses Step
uses 'docker/build-push-action' with ref 'v6', not a pinned commit hash
with:
push: true
tags: |
ghcr.io/theworldavatar/feature-info-agent:latest
ghcr.io/theworldavatar/feature-info-agent:${{ env.VERSION }}
ghcr.io/theworldavatar/feature-info-agent:${{ env.MAJOR }}
ghcr.io/theworldavatar/feature-info-agent:${{ env.MINOR }}
Loading
Loading