Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Replaced the latest version tag with a baked-in version #390

Merged
merged 74 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
9b934c3
Modified `build_docker_nightly` workflow
rmanaem Dec 3, 2024
03fdca8
Set `GH_TOKEN`
rmanaem Dec 3, 2024
4bcc1d7
A different approach
rmanaem Dec 3, 2024
99b3d63
Use shortened sha
rmanaem Dec 3, 2024
df384c7
Updated `build_docker_on_release` workflow
rmanaem Dec 4, 2024
4653948
Updated `deploy` workflow
rmanaem Dec 4, 2024
44ab88f
Removed fetching version from GitHub
rmanaem Dec 4, 2024
b33d5f2
Fixed typo
rmanaem Dec 4, 2024
189ce59
Reverted changes made to `deploy` workflow
rmanaem Dec 5, 2024
309a808
Added `bump_version` workflow
rmanaem Dec 5, 2024
4f34aa4
Updated `bump_version` workflow
rmanaem Dec 5, 2024
d28e9fc
Added the labeled type
rmanaem Dec 5, 2024
2f09538
Test different auto commands
rmanaem Dec 5, 2024
dc6b038
Merge branch 'main' into bug-291
rmanaem Dec 5, 2024
9c8bdc4
comment out the label condition
rmanaem Dec 5, 2024
5a623cc
Try canary command
rmanaem Dec 5, 2024
7dccb45
Added github token
rmanaem Dec 5, 2024
70b9c33
Let's try commands
rmanaem Dec 5, 2024
9cd9e97
let's try this solution
rmanaem Dec 7, 2024
698a351
Removed couple steps
rmanaem Dec 7, 2024
bfb43fe
Set the version_schema
rmanaem Dec 7, 2024
f627f54
Remove prerelease_suffix
rmanaem Dec 7, 2024
a352715
Removed default field
rmanaem Dec 7, 2024
d6449b1
Trying the latest version
rmanaem Dec 7, 2024
134d410
seems silly but worth a try
rmanaem Dec 7, 2024
5b9b98d
Installed auto as a dev dependency
rmanaem Dec 7, 2024
3a99f82
Bumped version in `package` files
rmanaem Dec 7, 2024
602c6a2
Let's try using npm
rmanaem Dec 7, 2024
f084501
Added GH_TOKEN
rmanaem Dec 7, 2024
ca0c485
Installed plugins
rmanaem Dec 7, 2024
dfcfccb
Grab the last line
rmanaem Dec 7, 2024
5def864
Installed the npm plugin explicitly
rmanaem Dec 7, 2024
2ef7561
Revert "Installed the npm plugin explicitly"
rmanaem Dec 7, 2024
54c1b10
Revert "Grab the last line"
rmanaem Dec 7, 2024
a56076d
Revert "Installed plugins"
rmanaem Dec 7, 2024
4b2aba8
Revert "Added GH_TOKEN"
rmanaem Dec 7, 2024
49a4b2b
Revert "Let's try using npm"
rmanaem Dec 7, 2024
33a928f
Revert "Bumped version in `package` files"
rmanaem Dec 7, 2024
f00746d
Revert "Installed auto as a dev dependency"
rmanaem Dec 7, 2024
3f8df34
Going back to version
rmanaem Dec 7, 2024
2f8a36e
Let's see the output
rmanaem Dec 7, 2024
98bec01
Read in a separate step
rmanaem Dec 7, 2024
f7a2ea6
Let's try this
rmanaem Dec 7, 2024
0c2bea2
try again
rmanaem Dec 7, 2024
a0e3583
Try verbose logs
rmanaem Dec 7, 2024
db69d0d
Really?
rmanaem Dec 7, 2024
b1c770a
ok does this work too?
rmanaem Dec 7, 2024
5b8d221
Getting there
rmanaem Dec 7, 2024
54d5374
Forgot the GH_TOKEN again
rmanaem Dec 7, 2024
3155484
Fixed the missing version
rmanaem Dec 7, 2024
8fd76a1
Let's run on pull_request
rmanaem Dec 7, 2024
65ad6d9
GH_TOKEN added
rmanaem Dec 7, 2024
087d263
Almost there
rmanaem Dec 7, 2024
5a0288d
Try a fix for committing to the same branch
rmanaem Dec 7, 2024
a7ef979
figuring out the right syntax
rmanaem Dec 7, 2024
221a5e2
an alternative appraoch
rmanaem Dec 7, 2024
2ff682c
Let's see what's in there
rmanaem Dec 7, 2024
85ed482
Let's check this one out
rmanaem Dec 7, 2024
6123cf6
This should do it
rmanaem Dec 7, 2024
ba6aec1
It's possible we didn't even needed the branch name
rmanaem Dec 7, 2024
38d6ce2
Try this syntax
rmanaem Dec 7, 2024
315d64b
Merge 38d6ce27f053a4cbeb29f3f358cefce48a7951b3 into 7a40a68c4de026fc3…
rmanaem Dec 7, 2024
b3cbe19
Bumped version to v0.7.2
neurobagel-bot[bot] Dec 7, 2024
80db23a
Added a condition to check diff before commiting
rmanaem Dec 7, 2024
bceed54
Refactor
rmanaem Dec 7, 2024
8564c74
Added a condition to skip the workflow when increment is empty
rmanaem Dec 7, 2024
6e524ef
Small refactor
rmanaem Dec 7, 2024
700c270
Removed the explicit condition and used label condition
rmanaem Dec 7, 2024
1c122f6
Merge 700c270cce43735d1e4a778124e7af8862126f90 into 7a40a68c4de026fc3…
rmanaem Dec 7, 2024
b154142
Bumped version to v0.7.2
neurobagel-bot[bot] Dec 7, 2024
493b08a
Updated `pull_request_template`
rmanaem Dec 7, 2024
cfb0f22
Reverted changes made to `build_docker_on_release`
rmanaem Dec 7, 2024
fa34e38
Fixed typo
rmanaem Dec 7, 2024
4ab3f86
Merge branch 'main' into bug-291
rmanaem Dec 10, 2024
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
2 changes: 2 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Changes proposed in this pull request:
-
-

**NOTE: If this pull request is to be released, the release label must be applied once the review process is done to avoid the local and remote from going out of sync as a consequence of the `bump version` workflow run**

<!-- To be checked off by reviewers -->
## Checklist
_This section is for the PR reviewer_
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/build_docker_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ jobs:
with:
submodules: recursive

- name: Fetch latest commit SHA from main branch
id: fetch_sha
run: |
git fetch origin main
LATEST_SHA=$(git rev-parse --short=7 origin/main)
echo "LATEST_SHA=$LATEST_SHA" >> $GITHUB_ENV

- name: Update package.json version
run: |
SHA=${{ env.LATEST_SHA }}
jq ".version = \"build:${SHA}\"" package.json > tmp.$$.json && mv tmp.$$.json package.json
cat package.json

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
Expand Down
90 changes: 90 additions & 0 deletions .github/workflows/bump_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: bump version

on:
pull_request:
types: [labeled]
workflow_dispatch:

permissions:
contents: write
pull-requests: write # Required to commit changes to PR branches

jobs:
bump-version:
runs-on: ubuntu-latest
if: ${{ github.event.label.name == 'release' }}
steps:
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.NB_BOT_ID }}
private-key: ${{ secrets.NB_BOT_KEY }}

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.generate-token.outputs.token }}

- name: Download latest auto
run: |
auto_download_url="$(curl -fsSL https://api.github.com/repos/intuit/auto/releases/latest | jq -r '.assets[] | select(.name == "auto-linux.gz") | .browser_download_url')"
wget -O- "$auto_download_url" | gunzip > ~/auto
chmod a+x ~/auto

- name: Get latest release version
id: latest-release
run: |
LATEST_TAG=$(curl -fsSL https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV

- name: Compute increment
id: compute-increment
run: |
# Run auto to determine version increment (patch, minor, major)
INCREMENT=$(~/auto version)
echo "Increment: $INCREMENT"
echo "INCREMENT=$INCREMENT" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}

- name: Bump version
id: bump-version
run: |
# Extract the current version from the latest release
VERSION=${{ env.LATEST_TAG }}
VERSION=${VERSION#v} # Remove the "v" prefix if it exists

IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"

# Increment based on the auto output
if [ "${{ env.INCREMENT }}" == "major" ]; then
((MAJOR++))
MINOR=0
PATCH=0
elif [ "${{ env.INCREMENT }}" == "minor" ]; then
((MINOR++))
PATCH=0
elif [ "${{ env.INCREMENT }}" == "patch" ]; then
((PATCH++))
fi

# Construct the new version
NEW_VERSION="v$MAJOR.$MINOR.$PATCH"
echo "New version: $NEW_VERSION"
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV

- name: Update package.json
run: |
jq ".version = \"$NEW_VERSION\"" package.json > package.json.tmp && mv package.json.tmp package.json
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}

- name: Commit and Push Changes
run: |
git config --global user.name "Neurobagel Bot"
git config --global user.email "neurobagel-bot[bot]@users.noreply.github.com"
git diff --quiet package.json || (git add package.json && git commit -m "Bumped version to $NEW_VERSION" && git push origin HEAD:${{ github.head_ref }})
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-query-tool",
"private": true,
"version": "0.1.0",
"version": "v0.7.2",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
20 changes: 3 additions & 17 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useState, useEffect } from 'react';
import axios from 'axios';
import { useState } from 'react';
import {
Toolbar,
Typography,
Expand All @@ -17,28 +16,15 @@ import Login from '@mui/icons-material/Login';
import Avatar from '@mui/material/Avatar';
import { useAuth0 } from '@auth0/auth0-react';
import { enableAuth } from '../utils/constants';
import packageJson from '../../package.json';
import logo from '../assets/logo.png';

function Navbar({ isLoggedIn, onLogin }: { isLoggedIn: boolean; onLogin: () => void }) {
const [latestReleaseTag, setLatestReleaseTag] = useState('');
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
const openAccountMenu = Boolean(anchorEl);

const { user, logout } = useAuth0();

useEffect(() => {
const GHApiURL = 'https://api.github.com/repos/neurobagel/query-tool/releases/latest';
axios
.get(GHApiURL)
.then((response) => {
const { data } = response;
setLatestReleaseTag(data.tag_name);
})
.catch(() => {
setLatestReleaseTag('beta');
});
}, []);

const handleClick = (event: React.MouseEvent<HTMLElement>) => {
setAnchorEl(event.currentTarget);
};
Expand All @@ -52,7 +38,7 @@ function Navbar({ isLoggedIn, onLogin }: { isLoggedIn: boolean; onLogin: () => v
<div className="flex items-center">
<img src={logo} alt="Logo" height="60" />
<div className="ml-4">
<Badge badgeContent={latestReleaseTag}>
<Badge badgeContent={packageJson.version || 'beta'}>
<Typography variant="h5">Neurobagel Query</Typography>
</Badge>
<Typography className="text-gray-500">
Expand Down
Loading