Skip to content

Commit

Permalink
ci: add create release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ambersariya committed Sep 29, 2021
1 parent e9ba099 commit 4e4a8f9
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 46 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10

name: Create Release

jobs:
autorelease:
name: Create Release
runs-on: "ubuntu-latest"
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.6"
- name: Permacache Poetry
id: cache-poetry
uses: actions/[email protected]
with:
path: ~/.poetry
key: poetry
- name: Install latest version of Poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: |
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
- name: Add Poetry to $PATH
run: |
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
- name: Add version to environment vars
run: |
PROJECT_VERSION=$(poetry version --short)
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
- name: Check if tag version matches project version
run: |
TAG=$(git describe HEAD --tags --abbrev=0)
echo $TAG
echo $PROJECT_VERSION
if [[ "$TAG" != "v$PROJECT_VERSION" ]]; then exit 1; fi
- name: Get Poetry version
run: poetry --version
- name: Check pyproject.toml validity
run: poetry check --no-interaction
- name: Cache dependencies
id: cache-deps
uses: actions/[email protected]
with:
path: ${{github.workspace}}/.venv
key: poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: poetry-
- name: Install deps
if: steps.cache-deps.cache-hit != 'true'
run: |
poetry config virtualenvs.in-project true
poetry install --no-interaction
- name: Run tests
run: poetry run pytest -v
- name: Build
run: poetry build
- name: Release Notes
run: git log $(git describe HEAD~ --tags --abbrev=0)..HEAD --pretty='format:* %h %s%n * %an <%ae>' --no-merges >> ".github/RELEASE-TEMPLATE.md"
- name: Create Release Draft
uses: softprops/action-gh-release@v1
with:
body_path: ".github/RELEASE-TEMPLATE.md"
draft: true
files: |
dist/checkip-${{env.PROJECT_VERSION}}-py3-none-any.whl
dist/checkip-${{env.PROJECT_VERSION}}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ambersariya/checkip
54 changes: 8 additions & 46 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,3 @@
# # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

# name: Python Build

# on:
# push:
# branches: [ main ]
# tags:
# - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
# pull_request:
# branches: [ main ]

# jobs:
# build:

# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# python-version: [3.6, 3.7, 3.8, 3.9]

# steps:
# - uses: actions/checkout@v2
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v2
# with:
# python-version: ${{ matrix.python-version }}
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip poetry
# poetry install
# - name: Lint with flake8
# run: |
# .venv/bin/black src
# - name: Test with pytest
# run: |
# .venv/bin/pytest
on:
push:
branches: [main]
Expand All @@ -51,7 +13,7 @@ defaults:
jobs:
black-formatting-check:
name: Check formatting
runs-on: 'ubuntu-latest'
runs-on: "ubuntu-latest"
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
Expand All @@ -63,14 +25,14 @@ jobs:
strategy:
matrix:
os:
- 'ubuntu-latest'
- 'macos-latest'
- 'windows-latest'
- "ubuntu-latest"
- "macos-latest"
- "windows-latest"
python-version:
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- "3.6"
- "3.7"
- "3.8"
- "3.9"
steps:
- name: Checkout code
uses: actions/[email protected]
Expand Down

0 comments on commit 4e4a8f9

Please sign in to comment.