I
I
Ilya Chichak2020-06-02 01:50:59
GitHub
Ilya Chichak, 2020-06-02 01:50:59

How to properly generate automatic releases on Github?

I'm trying to build automatic releases on Github Actions

In my view, it should be like this:
A feature is being worked on in a branch
A PR is being opened - tests, linters, etc. are chasing in it
if all tests are passed, the review has approved everything - Squash and merge

By merge to the master should occur building and publishing in Pypi - it works, I
want to set up automatic creation of a release on GitHub ,
I look at https://github.com/actions/create-release, but I can’t figure out how to get its header and body from the commit

Maybe it makes sense to do it through tagging or something else

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya Chichak, 2020-06-25
@ilya_chch

in general, I solved the problem:

name: Release

on:
  push:
    branches:
      - master

jobs:
  release:
    if: github.event_name == 'push' && github.ref == 'refs/heads/master'
    name: Release
    runs-on: ubuntu-latest
    steps:
      - name: Getting code
        uses: actions/[email protected]
      - name: Getting Python
        uses: actions/[email protected]
      - name: Cache pip
        uses: actions/[email protected]
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip-${{ hashFiles('poetry.lock') }}
          restore-keys: |
            ${{ runner.os }}-pip-
      - name: Getting Poetry
        uses: dschep/[email protected]
      - name: Getting PostgreSQL
        uses: harmon758/[email protected]
        with:
          postgresql db: 'test_db'
          postgresql user: 'postgres'
          postgresql password: 'postgres'
      - name: Installing dependencies
        run: poetry install
      - name: Running tests
        run: make coverage_run
      - name: Running coverage check
        run: make coverage_cmd_report
      - name: Running codestyle checks
        run: make check_black
      - name: Running types checks
        run: make check_mypy

      - name: Generate coverage report
        run: make coverage_xml_report
      - name: Upload coverage to Codecov
        uses: codecov/[email protected]
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          file: ./coverage.xml

      - name: Getting package version
        id: get_version
        run: echo "::set-output name=version::$(poetry version)"

      - name: Getting package clear version
        id: get_clear_version
        run: echo "::set-output name=clear_version::$(poetry version | cut -d ' ' -f 2)"

      - name: Make release and publish
        run: make release USERNAME=${{ secrets.PYPI_USERNAME }} TOKEN=${{ secrets.PYPI_TOKEN }}

      - name: Get asset name
        id: get_asset_name
        run: echo "::set-output name=assert_name::$(ls dist | grep gz)"

      - name: Create Release
        id: create_release
        uses: actions/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ steps.get_clear_version.outputs.clear_version }}
          release_name: ${{ steps.get_version.outputs.version }}
          draft: false
          prerelease: false

      - name: Upload Release assets
        id: upload_gz
        uses: actions/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: dist/${{ steps.get_asset_name.outputs.assert_name }}
          asset_name: ${{ steps.get_asset_name.outputs.assert_name }}
          asset_content_type: application/tar+gzip

N
Nick, 2020-06-02
@DragonSpirit

It all depends on how the commit history is kept.
As for me, it’s a good idea to hang up tags and collect history for the release through conditional git log tag1..tag2
as an option to look towards commitizen
and feed the resulting data already in the github action

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question