-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from tm-a-t/dev
Dev
- Loading branch information
Showing
54 changed files
with
1,757 additions
and
924 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
**/__pycache__/ | ||
venv/ | ||
guide/site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Build docker image | ||
on: | ||
workflow_call: {} | ||
|
||
env: | ||
DOCKERHUB_REPO: tgpy/tgpy | ||
|
||
jobs: | ||
Build-docker-image: | ||
name: Build docker image | ||
concurrency: release-docker | ||
if: github.event_name == 'push' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Setup Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Setup Buildx caching | ||
uses: actions/cache@v3 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Set release flag | ||
if: github.ref == 'refs/heads/master' | ||
run: sed -i "s/\(IS_DEV_BUILD *= *\).*/\1False/" tgpy/version.py | ||
|
||
- name: Set branch tag | ||
if: github.ref != 'refs/heads/master' | ||
run: | | ||
BRANCH_TAG=$DOCKERHUB_REPO:$(git rev-parse --abbrev-ref HEAD) | ||
echo "BRANCH_TAG=$BRANCH_TAG" >> $GITHUB_ENV | ||
echo "IMAGE_TAGS=$IMAGE_TAGS -t $BRANCH_TAG" >> $GITHUB_ENV | ||
- name: Set latest tag | ||
if: github.ref == 'refs/heads/master' | ||
run: | | ||
BRANCH_TAG=$DOCKERHUB_REPO:latest | ||
echo "BRANCH_TAG=$BRANCH_TAG" >> $GITHUB_ENV | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USER }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
- name: Build and push image | ||
run: | | ||
docker buildx build \ | ||
--platform linux/amd64,linux/arm64 \ | ||
-t $DOCKERHUB_REPO:$(git rev-parse --short HEAD) \ | ||
-t $BRANCH_TAG \ | ||
--cache-from "type=local,src=/tmp/.buildx-cache" \ | ||
--cache-to "type=local,dest=/tmp/.buildx-cache-new,mode=max" \ | ||
--push . | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,18 @@ name: Lint & release project | |
on: | ||
push: | ||
paths: | ||
- 'pyproject.toml' | ||
- 'poetry.lock' | ||
- 'tgpy/**' | ||
- '.github/workflows/main.yml' | ||
- '.github/workflows/docker.yml' | ||
pull_request: | ||
paths: | ||
- 'pyproject.toml' | ||
- 'poetry.lock' | ||
- 'tgpy/**' | ||
- '.github/workflows/main.yml' | ||
- '.github/workflows/docker.yml' | ||
|
||
jobs: | ||
Lint: | ||
|
@@ -94,3 +100,17 @@ jobs: | |
export REPOSITORY_USERNAME="__token__" | ||
export REPOSITORY_PASSWORD="${PYPI_TOKEN}" | ||
python -m semantic_release publish -D commit_author="github-actions <[email protected]>" | ||
Build-dev-docker: | ||
name: Build dev docker image | ||
if: github.event_name == 'push' && github.ref != 'refs/heads/master' | ||
uses: ./.github/workflows/docker.yml | ||
secrets: inherit | ||
|
||
Build-release-docker: | ||
name: Build release docker image | ||
needs: Release | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | ||
uses: ./.github/workflows/docker.yml | ||
secrets: inherit | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,5 @@ dist/ | |
data/ | ||
config.py | ||
config.yaml | ||
|
||
guide/site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# syntax=docker/dockerfile:1.3 | ||
FROM python:3.10-alpine as base | ||
WORKDIR /app | ||
|
||
FROM base as builder | ||
RUN apk add --no-cache gcc musl-dev libffi-dev git rust cargo | ||
|
||
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \ | ||
POETRY_VERSION=1.1.13 | ||
|
||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
pip install poetry==$POETRY_VERSION | ||
RUN python -m venv /venv | ||
|
||
COPY pyproject.toml poetry.lock ./ | ||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
poetry export -f requirements.txt | /venv/bin/pip install -r /dev/stdin | ||
|
||
COPY . . | ||
RUN git status | ||
RUN sed -i "s/\(COMMIT_HASH *= *\).*/\1'$(git rev-parse HEAD)'/" tgpy/version.py | ||
|
||
FROM base as runner | ||
COPY --from=builder /venv /venv | ||
COPY --from=builder /app/tgpy tgpy | ||
|
||
ENV TGPY_DATA=/data | ||
VOLUME /data | ||
|
||
ENTRYPOINT ["/venv/bin/python", "-m", "tgpy"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.