Skip to content

Commit

Permalink
Feature/ci rc (#31)
Browse files Browse the repository at this point in the history
updates CI
  • Loading branch information
saxix authored Jun 13, 2024
1 parent a0fa9dd commit adffd64
Show file tree
Hide file tree
Showing 42 changed files with 2,162 additions and 318 deletions.
23 changes: 23 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[bumpversion]
commit = False
tag = False
allow_dirty = True
tag_name = {new_version}
current_version = 0.1.0
parse = ^
(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
(-?(?P<prekind>(rc|final))
(?P<pre>\d+) # pre-release version num
)?
serialize =
{major}.{minor}.{patch}-{prekind}{pre}
{major}.{minor}.{patch}

[bumpversion:file:pyproject.toml]

[bumpversion:part:prekind]
optional_value = _
values =
_
rc
_
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_workflows/*
21 changes: 21 additions & 0 deletions .github/actions/distro_hash/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ref: https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action
name: 'Calculate Release Hash'
description: 'Calculate deps and os hash'
inputs:
files:
description: 'Files to use to calculate the hash'
required: true
default: "pdm.lock docker/bin/* docker/conf/* docker/Dockerfile"
outputs:
hash: # id of output
description: 'The time we greeted you'
value: ${{ steps.calc.outputs.hash }}

runs:
using: 'composite'
steps:
- id: calc
shell: bash
run: |
LOCK_SHA=$(sha1sum ${{ inputs.files }} | sha1sum | awk '{print $1}' | cut -c 1-8)
echo "hash=$LOCK_SHA" >> "$GITHUB_OUTPUT"
54 changes: 54 additions & 0 deletions .github/actions/docker_build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# ref: https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action
name: 'Calculate version hash'
description: 'Calculate deps and os hash'
inputs:
username:
description: ''
required: true
password:
description: ''
required: true
image:
description: ''
required: true
target:
description: ''
required: true


runs:
using: 'composite'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
tags: ${{vars.DOCKER_IMAGE}}:dev-latest
file: ./docker/Dockerfile
platforms: linux/amd64
cache-from: type=registry,ref=${{vars.DOCKER_IMAGE}}:dev-latest
cache-to: type=inline
outputs: type=registry
target: python_dev_deps
build-args: |
BUILD_DATE="${{ steps.build_date.outputs.date }}"
CHECKSUM="${{ steps.release_hash.outputs.hash }}"
VERSION="${{ steps.version.outputs.version }}"
- name: Calculate Release Hash
id: calc
shell: bash
run: |
docker pull ${{inputs.image}}
echo "----------"
docker inspect --format='{{json .Config.Labels}}' ${{inputs.image}}}}:dev-latest
docker run -t ${{inputs.image}}}}:dev-latest release-info.sh
echo "----------"
34 changes: 34 additions & 0 deletions .github/actions/docker_info/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ref: https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action
name: 'Retrieve Docker Image Information'
description: 'Calculate deps and os hash'
inputs:
image:
description: 'Files to use to calculate the hash'
required: true
username:
description: ''
required: true
password:
description: ''
required: true

runs:
using: 'composite'
steps:
# - name: Configure Git
# shell: bash
# run: git config --global --add safe.directory $(realpath .)
# - name: ch
# uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: docker/login-action@v3
with:
username: ${{ inputs.username }}
password: ${{ inputs.password }}
- name: Calculate Release Hash
shell: bash
run: |
docker pull ${{inputs.image}}
echo "----------"
docker inspect --format='{{json .Config.Labels}}' ${{inputs.image}}
docker run -t ${{inputs.image}} release-info.sh
echo "----------"
51 changes: 51 additions & 0 deletions .github/actions/env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'version'
description: ''

outputs:
stage:
description: ''
value: ${{ steps.version.outputs.stage }}
version:
description: ''
value: ${{ steps.version.outputs.version }}
commit:
description: ''
value: ${{ steps.version.outputs.commit }}
release:
description: ''
value: ${{ steps.version.outputs.release }}
date:
description: ''
value: ${{ steps.build_date.outputs.date }}
today:
description: ''
value: ${{ steps.build_date.outputs.today }}
timestamp:
description: ''
value: ${{ steps.build_date.outputs.timestamp }}
branch:
description: ''
value: ${{ steps.extract_branch.outputs.branch }}


runs:
using: 'composite'
steps:
- shell: bash --noprofile --norc -eo pipefail {0}
run: git config --global --add safe.directory $(realpath .)
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- id: version
uses: ./.github/actions/version
- id: extract_branch
name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
- id: build_date
shell: bash --noprofile --norc -eo pipefail -ux {0}
run: |
d1=$(date +"%a,%e %b %Y %H:%M %Z")
d2=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
d3=$(date -u +"%Y%m%d%H%M%S")
echo "today=$d1" >> $GITHUB_OUTPUT
echo "date=$d2" >> $GITHUB_OUTPUT
echo "timestamp=$d3" >> $GITHUB_OUTPUT
2 changes: 1 addition & 1 deletion .github/actions/image_exists/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ runs:
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "Image ${{inputs.image}} does not exist"
fi
fi
Loading

0 comments on commit adffd64

Please sign in to comment.