Skip to content

Commit

Permalink
Update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
chelnak committed Nov 14, 2022
1 parent fe6930e commit 26751ea
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 40 deletions.
79 changes: 39 additions & 40 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: status-cake-exporter
name: "ci"

on:
push:
Expand All @@ -7,51 +7,55 @@ on:
pull_request:
branches:
- main
workflow_dispatch:

env:
IMAGE_NAME: status-cake-exporter

jobs:
build:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"

steps:
- uses: actions/checkout@v2

- uses: "actions/checkout@v3"
with:
fetch-depth: 0
- name: Set up Python 🐍
uses: actions/setup-python@v2
fetch-depth: 0

- name: "set up python"
uses: "actions/setup-python@v2"
with:
python-version: 3.8
python-version: '3.10'

- name: Install Dependencies 🚧
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: "install poetry"
uses: "snok/install-poetry@v1"
with:
virtualenvs-in-project: true

- name: Lint 🍻
run: |
python -m flake8 exporter/ --max-line-length=120 --tee
- name: "install dependencies"
run: poetry install

# - name: Test ✅
# run: |
# python setup.py test
- name: "build"
run: |
source $VENV
make build
- name: Build image 🐳
run: docker build . --file Dockerfile --tag status-cake-exporter
- name: "get version"
id: "get_version"
run: |
current_version=$(poetry version -s)
echo "version=$current_version" >> $GITHUB_OUTPUT
- name: Log into registry 🐳
- name: "log into registry"
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push image 🐳
- name: "push image"
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
if [[ "${{ github.ref }}" == "refs/tags/v"* ]]; then
docker tag $IMAGE_NAME $IMAGE_ID:$(echo $VERSION | sed -e 's/^v//')
# latest should always reflect the most recent tagged release
VERSION=latest
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
Expand All @@ -61,26 +65,21 @@ jobs:
# dev represents the latest build from prs or branches
VERSION=dev
fi
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push -a $IMAGE_ID
env:
GITVERSION_MAJORMINORPATCH: ${{ steps.gitversion.outputs.majorMinorPatch }}
- name: Build Changelog 📝
- name: "create release"
if: startsWith(github.ref, 'refs/tags/v')
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v1
with:
configuration: "changelog.json"
run: |
gh release create v${{ steps.get_version.outputs.version }} ./pkg/*.gem --title v${{ steps.get_version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release 🚀
- name: "publish"
if: startsWith(github.ref, 'refs/tags/v')
id: create_release
uses: ncipollo/release-action@v1
with:
name: status-cake-exporter
body: ${{steps.build_changelog.outputs.changelog}}
token: ${{ secrets.GITHUB_TOKEN }}
run: |
poetry config pypi-token.pypi $POETRY_PYPI_TOKEN_PYPI
poetry publish
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}

74 changes: 74 additions & 0 deletions .github/workflows/release_prep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: "Release Prep"

on:
workflow_dispatch:
inputs:
version:
description: "The version number for the next release."
required: true
type: choice
options:
- patch
- minor
- majorpoetr

jobs:
release_prep:
name: "release prep"
runs-on: "ubuntu-latest"

steps:

- name: "checkout"
uses: "actions/checkout@v3"
with:
clean: true
fetch-depth: 0

- name: "set up python"
uses: "actions/setup-python@v2"
with:
python-version: '3.10'

- name: "install poetry"
uses: "snok/install-poetry@v1"
with:
virtualenvs-in-project: true

- name: "install dependencies"
run: |
poetry install
- name: "bump version"
id: "bump_version"
run: |
next_version=$(poetry version ${{ github.event.inputs.version }} -s)
echo "version=$next_version" >> $GITHUB_OUTPUT
- name: "generate changelog"
run: |
$ENV:GH_HOST='github.com'
gh extension install chelnak/gh-changelog
gh changelog new --next-version ${{ steps.bump_version.version }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: "commit changes"
run: |
git config --local user.email "${{ github.repository_owner }}@users.noreply.github.com"
git config --local user.name "GitHub Actions"
git add .
git commit -m "Release prep v${{ github.event.inputs.version }}"
- name: "create pull request"
uses: "peter-evans/create-pull-request@v4"
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Release prep v${{ github.event.inputs.version }}"
branch: "release-prep"
delete-branch: true
title: "Release prep v${{ github.event.inputs.version }}"
base: "main"
body: |
Automated release-prep from commit ${{ github.sha }}.
labels: "maintenance"

0 comments on commit 26751ea

Please sign in to comment.