2022-11-29 11:43:22 +00:00
|
|
|
# This script can be tested locally with act:
|
|
|
|
#
|
|
|
|
# act --secret GITHUB_TOKEN=... --job release
|
|
|
|
#
|
|
|
|
# https://github.com/nektos/act/
|
2023-01-05 11:02:39 +00:00
|
|
|
# To generate a token: https://github.com/settings/tokens (add r/w permissions for "Contents")
|
2021-05-17 13:39:46 +00:00
|
|
|
name: Release
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
tags:
|
|
|
|
- '*'
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
release:
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
include:
|
2022-11-29 11:43:22 +00:00
|
|
|
# https://github.com/actions/runner-images#available-images
|
2023-01-05 11:02:39 +00:00
|
|
|
# It's important that we build the tutor binaries with the *oldest* possible
|
|
|
|
# OS releases and Python version. See these docs for more information:
|
|
|
|
# https://pyinstaller.org/en/stable/usage.html#making-gnu-linux-apps-forward-compatible
|
|
|
|
- os: ubuntu-20.04
|
2021-05-17 13:39:46 +00:00
|
|
|
locale: C.UTF-8
|
2022-11-29 14:29:16 +00:00
|
|
|
gh_os: linux
|
2022-11-29 11:43:22 +00:00
|
|
|
# https://endoflife.date/macos
|
2023-01-05 11:02:39 +00:00
|
|
|
- os: macos-10.15
|
2021-05-17 13:39:46 +00:00
|
|
|
locale: en_US.UTF-8
|
2022-11-29 14:29:16 +00:00
|
|
|
gh_os: macOs
|
2021-05-17 13:39:46 +00:00
|
|
|
env:
|
|
|
|
LC_ALL: ${{ matrix.locale }}
|
|
|
|
LANG: ${{ matrix.locale }}
|
|
|
|
steps:
|
2022-11-29 14:29:16 +00:00
|
|
|
##### Setup environment
|
2022-11-29 11:43:22 +00:00
|
|
|
# https://github.com/actions/checkout
|
|
|
|
- uses: actions/checkout@v3
|
2021-05-17 13:39:46 +00:00
|
|
|
- name: Set up Python
|
2022-11-29 11:43:22 +00:00
|
|
|
# https://github.com/actions/setup-python
|
|
|
|
uses: actions/setup-python@v3
|
2021-05-17 13:39:46 +00:00
|
|
|
with:
|
2022-04-24 10:50:34 +00:00
|
|
|
python-version: 3.7
|
2022-11-29 11:43:22 +00:00
|
|
|
- name: Upgrade pip and setuptools
|
|
|
|
# https://pypi.org/project/pip/
|
|
|
|
# https://pypi.org/project/setuptools/
|
2022-12-12 20:26:37 +00:00
|
|
|
# https://pypi.org/project/wheel/
|
|
|
|
run: python -m pip install --upgrade pip setuptools==65.6.3 wheel
|
2021-05-17 13:39:46 +00:00
|
|
|
- name: Print info about the current python installation
|
|
|
|
run: make ci-info
|
|
|
|
- name: Install requirements
|
|
|
|
run: make bootstrap-dev-plugins
|
2022-11-29 14:29:16 +00:00
|
|
|
|
|
|
|
##### Run tests, generate bundle
|
2021-05-17 13:39:46 +00:00
|
|
|
- name: Run tests
|
2022-11-29 14:18:31 +00:00
|
|
|
run: make test
|
2021-05-17 13:39:46 +00:00
|
|
|
- name: Create bundle
|
|
|
|
run: make bundle
|
|
|
|
- name: Test bundle
|
|
|
|
run: make ci-test-bundle
|
2022-11-29 14:29:16 +00:00
|
|
|
|
|
|
|
##### Download gh utility: https://github.com/cli/cli/releases
|
2022-11-29 11:43:22 +00:00
|
|
|
- name: Check for presence of "gh" CLI utility
|
|
|
|
run: echo "gh_bin=$(which gh)" >> $GITHUB_ENV
|
2022-11-29 14:29:16 +00:00
|
|
|
- name: Download gh utility
|
2021-05-17 13:39:46 +00:00
|
|
|
run: |
|
2022-11-29 14:29:16 +00:00
|
|
|
curl -L -o gh.tar.gz https://github.com/cli/cli/releases/download/v2.20.2/gh_2.20.2_${{ matrix.gh_os }}_amd64.tar.gz
|
2022-11-29 11:43:22 +00:00
|
|
|
tar xzf gh.tar.gz
|
2022-11-29 14:29:16 +00:00
|
|
|
echo "gh_bin=./gh_2.20.2_${{ matrix.gh_os }}_amd64/bin/gh" >> $GITHUB_ENV
|
|
|
|
if: ${{ env.gh_bin == '' }}
|
|
|
|
|
|
|
|
##### Create release on GitHub
|
2022-11-29 11:43:22 +00:00
|
|
|
- name: Create or update GitHub release
|
|
|
|
# I wish there was an `--update` option to the `gh release create` command, but
|
|
|
|
# there isn't.
|
|
|
|
# https://cli.github.com/manual/gh_release_create
|
2021-05-17 13:39:46 +00:00
|
|
|
run: |
|
2022-11-29 11:43:22 +00:00
|
|
|
make release-description | tee release_description.md
|
2022-11-29 15:14:56 +00:00
|
|
|
export GH_ARGS="${{ github.ref_name }} --notes-file=release_description.md"
|
|
|
|
echo "gh args: '$GH_ARGS'"
|
2022-11-29 11:43:22 +00:00
|
|
|
${{ env.gh_bin }} release create $GH_ARGS || ${{ env.gh_bin }} release edit $GH_ARGS
|
2022-11-29 14:29:16 +00:00
|
|
|
env:
|
|
|
|
GH_TOKEN: ${{ github.token }}
|
2022-11-29 11:43:22 +00:00
|
|
|
- name: Upload release asset to GitHub
|
|
|
|
run: |
|
|
|
|
export FILENAME="tutor-$(uname -s)_$(uname -m)"
|
|
|
|
mv ./dist/tutor $FILENAME
|
2022-11-29 15:14:56 +00:00
|
|
|
${{ env.gh_bin }} release upload --clobber ${{ github.ref_name }} $FILENAME
|
2022-11-29 14:29:16 +00:00
|
|
|
env:
|
|
|
|
GH_TOKEN: ${{ github.token }}
|