Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6f96ea2

Browse files
committedApr 30, 2023
✨ Migrate to GitHub Actions + arm64 support
- Start building for platform linux/arm64 on debian - Use official docker actions - Pass version config as JSON - Inline git_versions.sh 🔥 Delete old CircleCI config
1 parent 92db13e commit 6f96ea2

17 files changed

+252
-325
lines changed
 

‎.circleci/config.yml

-37
This file was deleted.

‎.circleci/config_template.yml

-119
This file was deleted.

‎.github/workflows/build.yaml

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches: [chore/github-actions] # FIXME: main
6+
# branches: [main]
7+
schedule:
8+
- cron: "0 00,12 * * *" # Twice a day
9+
10+
jobs:
11+
generate-matrix:
12+
name: Generate Job Matrix
13+
runs-on: ubuntu-latest
14+
needs: [test]
15+
outputs:
16+
matrix: ${{ steps.set-matrix.outputs.matrix }}
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 2
21+
- uses: actions/setup-python@v4
22+
with:
23+
python-version: "3.11"
24+
cache: pipenv
25+
- run: |
26+
pip install pipenv
27+
pipenv install --deploy --dev
28+
- run: |
29+
FORCE=$(if git log --pretty=format:"%s" HEAD^..HEAD | grep -q '\[force\]'; then echo "--force"; else echo ""; fi)
30+
pipenv run python -m build_versions.main --ci-matrix $FORCE --ci-event ${{ github.event_name }}
31+
id: set-matrix
32+
33+
deploy:
34+
name: ${{ matrix.key }}
35+
runs-on: ubuntu-latest
36+
if: needs.generate-matrix.outputs.matrix != ''
37+
needs: [generate-matrix]
38+
strategy:
39+
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
40+
steps:
41+
- uses: actions/checkout@v3
42+
- uses: actions/setup-python@v4
43+
with:
44+
python-version: "3.11"
45+
cache: pipenv
46+
- run: |
47+
pip install pipenv
48+
pipenv install --deploy --dev
49+
- run: echo ${{ matrix.key }}
50+
- name: Generate Dockerfile from config
51+
run: pipenv run python -m build_versions.main --dockerfile-with-context '${{ toJSON(matrix) }}'
52+
- name: Set up QEMU
53+
uses: docker/setup-qemu-action@v2
54+
- name: Set up Docker Buildx
55+
uses: docker/setup-buildx-action@v2
56+
- name: Login to Docker Hub
57+
uses: docker/login-action@v2
58+
with:
59+
username: ${{ secrets.DOCKERHUB_USERNAME }}
60+
password: ${{ secrets.DOCKERHUB_TOKEN }}
61+
- name: Build and push
62+
uses: docker/build-push-action@v4
63+
with:
64+
context: .
65+
file: dockerfiles/${{ matrix.key }}.Dockerfile
66+
platforms: ${{ join(matrix.platforms) }}
67+
push: true
68+
tags: nikolaik/python-nodejs:${{ matrix.key }}-canary # FIXME: remove debug canary
69+
70+
release:
71+
name: Update versions.json and README.md
72+
runs-on: ubuntu-latest
73+
needs: [deploy]
74+
steps:
75+
- uses: actions/checkout@v3
76+
- uses: actions/setup-python@v4
77+
with:
78+
python-version: "3.11"
79+
cache: pipenv
80+
- run: |
81+
pip install pipenv
82+
pipenv install --deploy --dev
83+
- name: Update versions.json and README.md, then commit and push changes (if any)
84+
run: |
85+
# FIXME: remove --dry-run
86+
pipenv run python -m build_versions.main --verbose --release --dry-run
87+
clean_checkout=$(git status --porcelain)
88+
if [[ -n "${clean_checkout}" ]]; then
89+
git config --global user.name "Nikolai Kristiansen" > /dev/null 2>&1
90+
git config --global user.email nikolaik@users.noreply.github.com > /dev/null 2>&1
91+
92+
# Update README.md
93+
today=$(date +%Y-%m-%d)
94+
sed -i -E "s/Last updated by bot: .*/Last updated by bot: ${today}/" README.md
95+
96+
git add versions.json README.md
97+
git commit -m '🗃 Updated python/node versions [skip ci]'
98+
git push --quiet origin main
99+
else
100+
echo "Nothing changed, nothing to archive."
101+
fi
102+
103+
test:
104+
uses: ./.github/workflows/tests.yaml

‎.github/workflows/tests.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Tests
2+
3+
on:
4+
pull_request:
5+
workflow_call:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-python@v4
13+
with:
14+
python-version: "3.11"
15+
cache: pipenv
16+
- run: |
17+
pip install pipenv
18+
pipenv install --deploy --dev
19+
- run: pipenv run ./bin/lint
20+
- run: pipenv run ./bin/test

‎.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ debug-*.Dockerfile
22
.idea/
33
dockerfiles/
44
.circleci/config_generated.yml
5-
version_config.json
5+
version_config.json
6+
__pycache__

‎.python-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11.1

0 commit comments

Comments
 (0)
Please sign in to comment.