-
Notifications
You must be signed in to change notification settings - Fork 362
132 lines (116 loc) · 4.08 KB
/
release.yml
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# This is a GitHub workflow defining a set of jobs with a set of steps.
# ref: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
#
name: Publish
on:
pull_request:
paths-ignore:
- "docs/**"
- "**.md"
- "**.rst"
- ".github/workflows/*"
- "!.github/workflows/release.yml"
- ".pre-commit-config.yaml"
push:
paths-ignore:
- "docs/**"
- "**.md"
- "**.rst"
- ".github/workflows/*"
- "!.github/workflows/release.yml"
- ".pre-commit-config.yaml"
branches-ignore:
- "dependabot/**"
- "pre-commit-ci-update-config"
tags:
- "**"
workflow_dispatch:
jobs:
build-n-publish:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: install build requirements
run: |
pip install build
pip freeze
- name: build release
run: |
python -m build --sdist --wheel .
ls -l dist
# ref: https://github.com/actions/upload-artifact#readme
- uses: actions/upload-artifact@v3
with:
name: repo2docker-${{ github.sha }}
path: "dist/*"
if-no-files-found: error
# This step is only run when a new tag is pushed
# all previous steps always run in order to exercise them
- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_PASSWORD }}
publish-docker:
runs-on: ubuntu-22.04
env:
DEFAULT_REGISTRY: quay.io
IMAGE_NAME: jupyterhub/repo2docker
services:
# So that we can test this in PRs/branches
local-registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Should we push this image to a public registry?
run: |
if [ "${{ startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main') }}" = "true" ]; then
REGISTRY=$DEFAULT_REGISTRY
else
REGISTRY=localhost:5000
fi
echo "REGISTRY=$REGISTRY" >> $GITHUB_ENV
echo "Publishing to $REGISTRY"
# versioneer requires the full git history for non-tags
- uses: actions/checkout@v3
with:
fetch-depth: 0
# Setup docker to build for multiple platforms, see:
# https://github.com/docker/build-push-action/tree/v2.4.0#usage
# https://github.com/docker/build-push-action/blob/v2.4.0/docs/advanced/multi-platform.md
- name: Set up QEMU (for docker buildx)
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx (for multi-arch builds)
uses: docker/setup-buildx-action@v2
with:
# Allows pushing to registry on localhost:5000
driver-opts: network=host
- name: Setup push rights to Docker registry
if: env.REGISTRY != 'localhost:5000'
run: |
docker login -u "${{ secrets.DOCKER_REGISTRY_USERNAME }}" -p "${{ secrets.DOCKER_REGISTRY_TOKEN }}" "${{ env.REGISTRY }}"
# when building jupyter/repo2docker:master
# also push jupyter/repo2docker:1.2.3-3.abcd1234 (replace + with -)
- name: Get list of repo2docker docker tags
run: |
VERSION=$(python3 -c 'import versioneer; print(versioneer.get_version().replace("+", "-"))')
TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$VERSION"
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
TAGS="$TAGS,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main"
fi
if [ "${{ startsWith(github.ref, 'refs/tags/') }}" = "true" ]; then
TAGS="$TAGS,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
fi
echo "TAGS=$TAGS"
echo "TAGS=$TAGS" >> $GITHUB_ENV
- name: Build and push repo2docker
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.TAGS }}