diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml new file mode 100644 index 0000000..a504ab4 --- /dev/null +++ b/.gitea/workflows/publish.yaml @@ -0,0 +1,64 @@ +name: publish + +on: + push: + branches: + - "**" + workflow_dispatch: + +env: + REGISTRY: gcr.forust.xyz + IMAGE_NAME: forust/telegram-scraper + +jobs: + docker: + runs-on: [self-hosted, linux, arch, homelab] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Read project version + id: version + shell: bash + run: | + version="$(python3 - <<'PY' +from pathlib import Path +import tomllib + +print(tomllib.loads(Path("pyproject.toml").read_text())["project"]["version"]) +PY +)" + echo "version=$version" >> "$GITHUB_OUTPUT" + + - name: Log in to registry + shell: bash + run: | + echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "${REGISTRY}" \ + -u "${{ secrets.REGISTRY_USERNAME }}" \ + --password-stdin + + - name: Build and push image + shell: bash + run: | + image="${REGISTRY}/${IMAGE_NAME}" + tags=("latest" "${{ steps.version.outputs.version }}") + + case "${GITHUB_REF_NAME}" in + main) + tags+=("main" "prod") + ;; + dev) + tags+=("dev") + ;; + esac + + build_args=() + for tag in "${tags[@]}"; do + build_args+=(-t "${image}:${tag}") + done + + docker build "${build_args[@]}" . + + for tag in "${tags[@]}"; do + docker push "${image}:${tag}" + done diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..a504ab4 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,64 @@ +name: publish + +on: + push: + branches: + - "**" + workflow_dispatch: + +env: + REGISTRY: gcr.forust.xyz + IMAGE_NAME: forust/telegram-scraper + +jobs: + docker: + runs-on: [self-hosted, linux, arch, homelab] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Read project version + id: version + shell: bash + run: | + version="$(python3 - <<'PY' +from pathlib import Path +import tomllib + +print(tomllib.loads(Path("pyproject.toml").read_text())["project"]["version"]) +PY +)" + echo "version=$version" >> "$GITHUB_OUTPUT" + + - name: Log in to registry + shell: bash + run: | + echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "${REGISTRY}" \ + -u "${{ secrets.REGISTRY_USERNAME }}" \ + --password-stdin + + - name: Build and push image + shell: bash + run: | + image="${REGISTRY}/${IMAGE_NAME}" + tags=("latest" "${{ steps.version.outputs.version }}") + + case "${GITHUB_REF_NAME}" in + main) + tags+=("main" "prod") + ;; + dev) + tags+=("dev") + ;; + esac + + build_args=() + for tag in "${tags[@]}"; do + build_args+=(-t "${image}:${tag}") + done + + docker build "${build_args[@]}" . + + for tag in "${tags[@]}"; do + docker push "${image}:${tag}" + done diff --git a/pyproject.toml b/pyproject.toml index 55d89ab..12ea529 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "telegram-scraper" -version = "0.1.0" +version = "2.0.0" description = "Telegram-scraper with webui" readme = "README.md" requires-python = ">=3.11"