Skip to content

Commit 356c207

Browse files
Update CI workflows.
We have setup a workflow for releasing codecov-cli. Currently it runs on every push to master. If you look at the releases page there are MANY releases being created as drafts. That polutes the visibility of true releases. Furthermore, the only asset we have being built works only on Linux distros, and we'd like to provide something for macos and windows users as well. We also have redundant CI jobs for PRs and master on push. To address all those concerns, first we are updating the CI workflows. `push_flow.yml` will run the lint-build-test steps for every push we have. This also uploades test coverage to codecov. `release_flow.yml` takes care of building new releases. It only runs when a new TAG is pushed, starting with `v` (for versions). To help us use the new release flow a new command is begin added to Makefile, the `tag.release` command. It should be used as `make tag.release version=v0.1.0`, for example. It takes care of tagging a new release and uploading it to GitHub, hopefully triggering the release_flow as well. The changes for `release_flow.yml` were inspired by [this tutorial](https://data-dive.com/multi-os-deployment-in-cloud-using-pyinstaller-and-github-actions/)
1 parent 735de5f commit 356c207

4 files changed

Lines changed: 127 additions & 114 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 93 deletions
This file was deleted.
Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

4-
name: Python package
4+
name: Build-Test-Upload
55

6-
on:
7-
push:
8-
branches: [ master ]
9-
pull_request:
10-
branches: [ master ]
6+
on: [push] # Run on any push event
117

128
jobs:
139
lint:
@@ -27,13 +23,10 @@ jobs:
2723
run: |
2824
isort --check --profile=black codecov_cli -p staticcodecov_languages
2925
30-
31-
build:
32-
26+
build-test-upload:
3327
runs-on: ubuntu-latest
3428
strategy:
3529
fail-fast: false
36-
3730
steps:
3831
- uses: actions/checkout@v3
3932
with:
@@ -48,15 +41,16 @@ jobs:
4841
python -m pip install --upgrade pip
4942
python setup.py develop
5043
pip install -r requirements.txt
44+
- name: Create commit in codecov
45+
run: |
46+
codecovcli create-commit -t ${{ secrets.CODECOV_TOKEN }} --git-service github
47+
- name: Create commit report in codecov
48+
run: |
49+
codecovcli create-report -t ${{ secrets.CODECOV_TOKEN }} --git-service github
5150
- name: Test with pytest
5251
run: |
5352
pytest --cov
54-
- name: Dogfooding codecov-cli. Use codecov-cli to upload to codecov
53+
- name: Dogfooding codecov-cli. Use codecov-cli to upload to codecov (new upload endpoint)
5554
run: |
56-
codecovcli do-upload -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag cli3.10 --flag python3.10
57-
# - name: Upload to codecov
58-
# run: |
59-
# pip install codecov
60-
# codecov -t ${{ secrets.CODECOV_TOKEN }} -F python3.10
61-
55+
codecovcli do-upload --fail-on-error -t ${{ secrets.CODECOV_TOKEN }} --plugin pycoverage --flag python3.10
6256

.github/workflows/release_flow.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Build-and-Release
5+
6+
on:
7+
push:
8+
tags:
9+
- 'v*' # Runs only for tags that start with v (new versions)
10+
11+
jobs:
12+
createrelease:
13+
name: Create Release
14+
runs-on: [ubuntu-latest]
15+
steps:
16+
- name: Create Release
17+
id: create_release
18+
uses: actions/create-release@v1
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
with:
22+
tag_name: ${{ github.ref }}
23+
release_name: Release ${{ github.ref }}
24+
draft: false
25+
prerelease: false
26+
- name: Output Release URL File
27+
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt
28+
- name: Save Release URL File for publish
29+
uses: actions/upload-artifact@v1
30+
with:
31+
name: release_url
32+
path: release_url.txt
33+
34+
35+
- name: Build executable with pyinstaller
36+
run: |
37+
pip install pyinstaller
38+
pyinstaller -F codecov_cli/main.py
39+
40+
build-assets:
41+
name: Build packages
42+
needs: createrelease
43+
runs-on: ${{ matrix.os }}
44+
strategy:
45+
matrix:
46+
include:
47+
- os: macos-latest
48+
TARGET: macos
49+
CMD_BUILD: >
50+
pyinstaller -F codecov_cli/main.py &&
51+
cd dist/ &&
52+
zip -r9 codecovcli_macos_${{github.ref}} main.app/
53+
OUT_FILE_NAME: codecovcli_macos_${{github.ref}}.zip
54+
ASSET_MIME: application/zip
55+
- os: ubuntu-latest
56+
TARGET: ubuntu
57+
CMD_BUILD: >
58+
pyinstaller -F codecov_cli/main.py &&
59+
cp ./dist/main ./dist/codecovcli_linux_${{github.ref}}
60+
OUT_FILE_NAME: codecovcli_linux_${{github.ref}}
61+
ASSET_MIME: application/octet-stream
62+
- os: windows-latest
63+
TARGET: windows
64+
CMD_BUILD: >
65+
pyinstaller -F codecov_cli/main.py &&
66+
cp ./dist/main.exe ./dist/codecovcli_windows_${{github.ref}}.exe
67+
OUT_FILE_NAME: codecovcli_windows_${{github.ref}}.exe
68+
ASSET_MIME: application/vnd.microsoft.portable-executable
69+
steps:
70+
- uses: actions/checkout@v3
71+
with:
72+
submodules: true
73+
- name: Set up Python 3.10
74+
uses: actions/setup-python@v3
75+
with:
76+
python-version: "3.10"
77+
- name: Install pyinstaller
78+
run: pip install pyinstaller
79+
- name: Build with pyinstaller for ${{matrix.TARGET}}
80+
run: ${{matrix.CMD_BUILD}}
81+
- name: Load Release URL File from release job
82+
uses: actions/download-artifact@v1
83+
with:
84+
name: release_url
85+
- name: Get Release File Name & Upload URL
86+
id: get_release_info
87+
shell: bash
88+
run: |
89+
value=`cat release_url/release_url.txt`
90+
echo ::set-output name=upload_url::$value
91+
- name: Upload Release Asset
92+
id: upload-release-asset
93+
uses: actions/upload-release-asset@v1
94+
env:
95+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96+
with:
97+
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
98+
asset_path: ./dist/${{ matrix.OUT_FILE_NAME }}
99+
asset_name: ${{ matrix.OUT_FILE_NAME }}
100+
asset_content_type: ${{ matrix.ASSET_MIME }}
101+

Makefile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
name ?= codecovcli
2+
# Semantic versioning format https://semver.org/
3+
tag_regex := ^v([0-9]{1,}\.){2}[0-9]{1,}([-_]\w+)?$
24

35
lint:
46
pip install black==22.3.0 isort==5.10.1
5-
black codecov_cli/**
6-
isort --profile black codecov_cli/**
7-
black tests/**
8-
isort --profile black tests/**
7+
black codecov_cli
8+
isort --profile=black codecov_cli -p staticcodecov_languages
9+
black tests
10+
isort --profile black tests
11+
12+
tag.release:
13+
ifeq ($(shell echo ${version} | egrep "${tag_regex}"),)
14+
@echo "Version '${version}' is not a valid git tag.\nUsage: make tag.release version=v0.0.0"
15+
else
16+
@echo "Tagging new release ${version}"
17+
git tag -a ${version} -m "Autogenerated release tag for codecov-cli"
18+
git push origin ${version}
19+
endif

0 commit comments

Comments
 (0)