Skip to content

Commit

Permalink
Merge branch 'feature/python-package-check' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce17 committed Dec 30, 2020
2 parents 1f3fb0d + 9e5750e commit fa9b7f7
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 3 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/build_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ name: 'build images'
on:
push:
branches:
- '**'
# FIXME: only disable for testing purposes
# - '**'
- 'main'
tags:
- 'v*'

Expand All @@ -24,14 +26,21 @@ jobs:
id: prep
run: |
PREPARED_BUILD_VERSION=${BUILD_VERSION}
CURRENT_BRANCH=undef
# If this is git tag, use the tag name
if [[ $GITHUB_REF == refs/tags/* ]]; then
PREPARED_BUILD_VERSION=${GITHUB_REF#refs/tags/v}
fi
# If this is git branch, use the branch name
if [[ $GITHUB_REF == refs/heads/* ]]; then
CURRENT_BRANCH=${GITHUB_REF#refs/heads/}
fi
# Set output parameters.
echo ::set-output name=prepared_build_version::${PREPARED_BUILD_VERSION}
echo ::set-output name=current_branch::${CURRENT_BRANCH}
- name: Docker meta
id: docker_meta
Expand Down Expand Up @@ -64,7 +73,7 @@ jobs:
${{ runner.os }}-buildx-
- name: Login to DockerHub
if: github.event_name != 'pull_request'
if: github.event_name != 'pull_request' && steps.prep.outputs.current_branch == 'main'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
Expand All @@ -77,7 +86,7 @@ jobs:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
push: ${{ github.event_name != 'pull_request' }}
push: ${{ github.event_name != 'pull_request' && steps.prep.outputs.current_branch == 'main' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/check_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
name: 'check python package'

on:
schedule:
- cron: "0 0 * * 0"

jobs:
check:
runs-on: ubuntu-latest

env:
PY_PACKAGE_NAME: opencanary

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Get latest package version
uses: Bruce17/ghaction-package-latest-version@v1
id: pkg_version
with:
package: ${{ env.PY_PACKAGE_NAME }}
language: python
conditions: |
pythonVersion: py3
requiresPython: 3.7
- name: Get previous tag
id: previoustag
uses: WyriHaximus/[email protected]

- name: Create a new tag
uses: negz/create-tag@v1
if: steps.pkg_version.outputs.latestVersion != steps.previoustag.outputs.tag
with:
version: v${{ steps.pkg_version.outputs.latestVersion }}
message: ''
token: ${{ secrets.GITHUB_TOKEN }}

- name: Create new release for the new tag
uses: actions/create-release@v1
if: steps.pkg_version.outputs.latestVersion != steps.previoustag.outputs.tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.pkg_version.outputs.latestVersion }}
release_name: Release v${{ steps.pkg_version.outputs.latestVersion }}
body: |
Automatically created release by GitHub Action
draft: true
prerelease: false

0 comments on commit fa9b7f7

Please sign in to comment.