Skip to content

Commit

Permalink
fixed merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmitchellv committed May 5, 2023
2 parents 434a612 + 6632a53 commit 191e27e
Show file tree
Hide file tree
Showing 44 changed files with 1,366 additions and 207 deletions.
11 changes: 11 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
changelog:
categories:
- title: 🏕 Features
labels:
- '*'
exclude:
labels:
- dependencies
- title: 👒 Dependencies
labels:
- dependencies
Original file line number Diff line number Diff line change
@@ -1,48 +1,37 @@
name: Build containers
name: Build Release Specific Containers

on:
workflow_call:
inputs:
container-tag:
type: string
required: true
workflow_dispatch:
push:
branches:
- main
paths:
- "containers/**"
- ".github/workflows/buildContainers.yaml"
inputs:
container-tag:
type: string
required: true

jobs:
list-containers:
# Get a list of all the directories within containers/.
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./containers
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get install jq
- id: make-list
name: Generate list of directories within containers/
# use jq to produce json output and filter out the empty item caused by final newline
run: |
echo "::set-output name=containers::$(ls -d * | jq -R -s -c 'split("\n")[:-1]')"
outputs:
container-dirs: ${{steps.make-list.outputs.containers}}
uses: ./.github/workflows/listContainers.yaml
build:
name: Build containers
needs: list-containers
runs-on: ubuntu-latest
strategy:
matrix:
container-to-build: ${{fromJson(needs.list-containers.outputs.container-dirs)}}
container-to-build: ${{fromJson(needs.list-containers.outputs.containers)}}
permissions:
contents: "read"
id-token: "write"
packages: "write"
steps:
- name: Check Out Changes
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ inputs.container-tag }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -59,6 +48,20 @@ jobs:
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}/${{matrix.container-to-build}}
# this sets the version for tags and labels for each of the containers to be
# be the same as the version/tag where the code was pulled from
tags: |
type=semver,pattern={{raw}},value=${{ inputs.container-tag }}
type=ref,event=branch
type=ref,event=tag,pattern={{raw}},value=${{ inputs.container-tag }}
labels: |
org.opencontainers.image.version=${{ inputs.container-tag }}
- name: Target phdi release in requirements.txt
working-directory: ./containers/${{matrix.container-to-build}}
run: |
sed 's/phdi @ git+https:\/\/github.com\/CDCgov\/phdi.git@main/phdi @ git+https:\/\/github.com\/CDCgov\/phdi.git@${{ inputs.container-tag }}/g' requirements.txt > requirements_new.txt && mv requirements_new.txt requirements.txt
- name: Build and push
uses: docker/build-push-action@v3
Expand Down
218 changes: 218 additions & 0 deletions .github/workflows/createNewRelease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
name: Create New Release
on:
push:
branches:
- main

# Run all tests before making a release
jobs:
# Only make a release if commit contains [RELEASE]
check-commit-message:
runs-on: ubuntu-latest
outputs:
contains_release: ${{ steps.commit_check.outputs.contains_release }}
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Check commit message for [RELEASE]
id: commit_check
run: |
if [[ "${{ github.event.head_commit.message }}" == *"[RELEASE]"* ]]; then
echo "contains_release=true" >> $GITHUB_OUTPUT
else
echo "contains_release=false" >> $GITHUB_OUTPUT
fi
test-for-release:
needs: check-commit-message
if: ${{ needs.check-commit-message.outputs.contains_release == 'true' }}
uses: ./.github/workflows/test.yaml
tag-release:
name: Update phdi init version number
needs: test-for-release
permissions:
contents: write
outputs:
version: ${{ steps.get_version.outputs.version }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
ref: 'main'
- name: Install poetry and dependencies
run: |
pip install poetry
# update the version number in the phdi/__init.py__ file
- name: Get PHDI Version
id: get_version
run: |
VERSION_WITH_PHDI=$(poetry version)
echo "version=${VERSION_WITH_PHDI:5}" >> $GITHUB_OUTPUT
# Create new release tag
- name: Set up Git user
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Tag Release
run: |
git tag ${{ steps.get_version.outputs.version }}
git push origin ${{ steps.get_version.outputs.version }}
# Create new release based upon the latest created tag
- name: Create Release
id: create_release
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.version }}
release_name: Release ${{ steps.get_version.outputs.version }}

release-to-pypi:
name: Build and publish PHDI to PyPI
needs: tag-release
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
ref: ${{ needs.tag-release.outputs.version }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}

# Rebuild all containers for the new release
build-containers-for-release:
needs: tag-release
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/buildReleaseContainers.yaml
with:
container-tag: ${{ needs.tag-release.outputs.version }}

# Create updated PHDI docs for the latest release
generate-and-update-phdi-docs:
needs:
- tag-release
- build-containers-for-release
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
ref: ${{ needs.tag-release.outputs.version }}

- name: Install poetry and dependencies
run: |
pip install poetry
poetry install
- name: Generate docs and move to docs branch
run: |
poetry run pdoc ./phdi -o ./docs/${{ needs.tag-release.outputs.version }}/sdk
- uses: actions/upload-artifact@v3
with:
name: phdi-docs
path: ./docs/${{ needs.tag-release.outputs.version }}/sdk

# Create updated container docs for the latest release
list-containers:
needs: check-commit-message
if: ${{ needs.check-commit-message.outputs.contains_release == 'true' }}
uses: ./.github/workflows/listContainers.yaml
generate-and-update-container-docs:
needs:
- tag-release
- list-containers
- generate-and-update-phdi-docs
permissions:
contents: write
runs-on: ubuntu-latest
strategy:
matrix:
container: ${{fromJson(needs.list-containers.outputs.containers)}}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
ref: ${{ needs.tag-release.outputs.version }}

- name: Update Container Documenation
run: |
npm i -g redoc-cli
CONTAINER=${{ matrix.container }}
cd $GITHUB_WORKSPACE/containers/$CONTAINER
cp $GITHUB_WORKSPACE/utils/make_openapi_json.py .
pip install -r requirements.txt
python make_openapi_json.py
redoc-cli build -o $GITHUB_WORKSPACE/docs/${{ needs.tag-release.outputs.version }}/containers/$CONTAINER.html openapi.json
- uses: actions/upload-artifact@v3
with:
name: container-docs
path: ./docs/${{ needs.tag-release.outputs.version }}/containers

commit-docs:
needs:
- tag-release
- generate-and-update-phdi-docs
- generate-and-update-container-docs
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: docs

- name: Download phdi docs from artifacts
uses: actions/download-artifact@v2
with:
name: phdi-docs
path: ./docs/${{ needs.tag-release.outputs.version }}/sdk

- name: Download container docs from artifacts
uses: actions/download-artifact@v2
with:
name: container-docs
path: ./docs/${{ needs.tag-release.outputs.version }}/containers

- name: Copy to latest folder
run: |
rm -rf ./docs/latest
mkdir -p ./docs/latest/sdk
mkdir -p ./docs/latest/containers
cp -r ./docs/${{ needs.tag-release.outputs.version }}/sdk/* ./docs/latest/sdk
cp -r ./docs/${{ needs.tag-release.outputs.version }}/containers/* ./docs/latest/containers
- name: Commit New Documentation
uses: EndBug/add-and-commit@v9
with:
add: docs
message: Automated update of docs for ${{ needs.tag-release.outputs.version }} release.
26 changes: 26 additions & 0 deletions .github/workflows/listContainers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "List Containers"

on:
workflow_call:
outputs:
containers:
value: ${{ jobs.list-containers.outputs.container-dirs }}

jobs:
list-containers:
runs-on: ubuntu-latest
outputs:
container-dirs: ${{steps.generate-list.outputs.containers}}
steps:
- name: Check Out Changes
uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get install jq
- id: generate-list
name: Generate list of directories within containers/
working-directory: ./containers
# use jq to produce json output and filter out the empty item caused by final newline
run: |
ls -d * | jq -R -s -c 'split("\n")[:-1]'
echo "containers=$(ls -d */ | cut -f1 -d'/' | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
55 changes: 0 additions & 55 deletions .github/workflows/tagRelease.yaml

This file was deleted.

Loading

0 comments on commit 191e27e

Please sign in to comment.