forked from opensafely-core/job-runner
-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (71 loc) · 2.19 KB
/
build_and_publish.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Tag repo; build and publish assets
on:
push:
branches:
- master
# this allows us to trigger manually
workflow_dispatch:
env:
IMAGE_NAME: job-runner
jobs:
tag-new-version:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.new_tag }}
version: ${{ steps.tag.outputs.new_version }}
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
- name: Bump version and push tag
id: tag
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: false
release_branches: master
build-and-publish-package:
runs-on: ubuntu-latest
name: Build and publish PyPI package
needs: tag-new-version
if: needs.tag-new-version.outputs.tag
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install wheel package
run: |
pip install wheel
- name: Generate correct value for VERSION file
run: |
echo ${{ needs.tag-new-version.outputs.tag }} > VERSION
- name: Build package
run: |
python setup.py sdist bdist_wheel
- name: Publish package
uses: pypa/gh-action-pypi-publish@master
if: needs.tag-new-version.outputs.tag
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
build-and-publish-docker-image:
runs-on: ubuntu-latest
name: Build and publish docker image
# Only on a tagged release
needs: tag-new-version
if: needs.tag-new-version.outputs.tag
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME --build-arg=pythonversion=3.8.3
- name: Log into GitHub Container Registry
run: docker login https://ghcr.io -u ${{ github.actor }} --password ${{ secrets.DOCKER_RW_TOKEN }}
- name: Push image to GitHub Container Registry
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
docker tag $IMAGE_NAME $IMAGE_ID:latest
docker push $IMAGE_ID:latest