Skip to content

Commit

Permalink
introduce release pipeline
Browse files Browse the repository at this point in the history
add run link to VERSION_D.html
comment sourceversion script so that future programmers hate me less
add tag-release workflow
correct old mistakes that were found underway
  • Loading branch information
MajoBerger authored Mar 1, 2024
1 parent 5fb2ccf commit 6a16eb1
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
deploy:
needs: dspace-angular
uses: dataquest-dev/dspace-angular/.github/workflows/deploy.yml@dtq-dev
if: ${{ github.event_name != 'pull_request' }}
with:
INSTANCE: '5'
IMPORT: false
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release

on:
push:
tags:
- '**'

env:
IMAGE_BASE_NAME: dataquest/dspace-angular

jobs:
retag-FE-image:
steps:
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}

- name: retag image
run: |
docker pull ${{ env.IMAGE_BASE_NAME }}:${{ github.sha }}
docker tag ${{ env.IMAGE_BASE_NAME }}:${{ github.sha }} ${{ env.IMAGE_BASE_NAME }}:${{ github.ref_name }}
- name: push image
run: docker push ${{ env.IMAGE_BASE_NAME }}:${{ github.ref_name }}

27 changes: 21 additions & 6 deletions scripts/sourceversion.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
import subprocess
import sys
from datetime import datetime

# when next editing this script, please introduce argparse.
# do not forget, it is called in BE by .github\workflows\reusable-docker-build.yml
# argparse must be introduced there.
# that action also calls BE version of this script, which is different (BE: scripts/sourceversion.py).
# It must also cooperate with argparse

# the idea is, that this will be different on each branch, but could be possibly passed by argv/argparse
RELEASE_TAG_BASE='none'

if __name__ == '__main__':
ts = datetime.now()
print(f"timestamp: {ts}")
# we have html tags, since this script ends up creating VERSION_D.html
print(f"<h4>This info was generated on: <br> <strong> {ts} </strong> </h4>")

cmd = 'git log -1 --pretty=format:"%h - %ai"'
print(f">{cmd}")
cmd = 'git log -1 --pretty=format:"<h4>Git hash: <br><strong> %H </strong> <br> Date of commit: <br> <strong> %ai </strong></h4>"'
subprocess.check_call(cmd, shell=True)

cmd = 'git status --porcelain'
print(f">{cmd}:")
subprocess.check_call(cmd, shell=True)
# when adding argparse, this should be a bit more obvious
link = sys.argv[1] + sys.argv[2]
print('<br> <h4>Build run: </h4> <a href="' + link + '"> ' + link + '</a> ')

link = "https://github.com/dataquest-dev/dspace-angular/releases/tag/" \
+ RELEASE_TAG_BASE + "-" + datetime.now().strftime('%Y.%m.') + sys.argv[2]

print('<br> <br> <h4>Release link: </h4><a href="' + link + '"> ' + link + '</a> (if it does not work, then this is not an official release instance) ')

0 comments on commit 6a16eb1

Please sign in to comment.