Skip to content

Commit

Permalink
Merge pull request #673 from conda-forge/release
Browse files Browse the repository at this point in the history
feat: tag release
  • Loading branch information
beckermr authored Sep 14, 2024
2 parents 8ff0bea + 1490315 commit 5ed3d91
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true)$
ref-names: $Format:%D$
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git_archival.txt export-subst
92 changes: 92 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: release

on:
workflow_dispatch: null
push:
branches:
- main

env:
PY_COLORS: "1"
IMAGE_NAME: condaforge/conda-forge-webservices

concurrency:
group: release
cancel-in-progress: false

jobs:
release:
name: release
runs-on: "ubuntu-latest"
defaults:
run:
shell: bash -leo pipefail {0}

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0

- uses: mamba-org/setup-micromamba@f8b8a1e23a26f60a44c853292711bacfd3eac822 # v1
with:
environment-file: conda-lock.yml
environment-name: webservices
condarc: |
show_channel_urls: true
channel_priority: strict
channels:
- conda-forge
- name: compute next version
id: version
run: |
echo "current version: "$(git describe --tags --abbrev=0)
NEXT=$(python scripts/compute_next_version.py)
echo "next version: ${NEXT}"
echo "NEXT=${NEXT}" >> "$GITHUB_OUTPUT"
# TODO: move webservices-dispatch-action to this repo and push via the following
# - name: set up docker buildx
# uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3

# - name: login to docker hub
# uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
# with:
# username: condaforgebot
# password: ${{ secrets.CF_BOT_DH_PASSWORD }}

# - name: build docker metadata
# id: meta
# uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5
# with:
# images: ${{ env.IMAGE_NAME }}
# flavor: |
# latest=false
# tags: |
# type=raw,value=${{ steps.version.outputs.NEXT }}
# type=raw,value=latest

# - name: build and push image
# uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6
# with:
# context: .
# push: true
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}

# - name: push README to docker hub
# uses: christian-korneck/update-container-description-action@d36005551adeaba9698d8d67a296bd16fa91f8e8 # v1
# env:
# DOCKER_USER: condaforgebot
# DOCKER_PASS: ${{ secrets.CF_BOT_DH_PASSWORD }}
# with:
# destination_container_repo: ${{ env.IMAGE_NAME }}:latest
# provider: dockerhub
# short_description: "conda-forge-webservices image used to power the admin webservices GitHub Actions integrations"
# readme_file: "Dockerfile_README.md"

- name: tag and release
run: |
python scripts/release.py "${{ steps.version.outputs.NEXT }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ recipe/*
.pytest_cache/
.ruff_cache/
built_dists/
conda_forge_webservices/_version.py
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies:
- ruamel.yaml >=0.16
- ruamel.yaml.jinja2
- setuptools
- setuptools_scm >=8
- shellcheck
- tini
- tornado
Expand Down
16 changes: 12 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
[build-system]
requires = ["setuptools>=61.0"]
requires = [
"setuptools>=61.0",
"setuptools_scm>=8",
"tomli>=1.0.0; python_version < '3.11'",
]
build-backend = "setuptools.build_meta"

[project]
name = "conda-forge-webservices"
version = "1.0"
dynamic = ["version"]
authors = [{ name = "Phil Elson", email = "[email protected]" }]
description = "Conda Forge Webservices"
description = "Conda-forge Webservices"
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
Expand All @@ -27,6 +31,10 @@ cache-status-data = "conda_forge_webservices.status_monitor:cache_status_data"
packages = ["conda_forge_webservices"]
include-package-data = true

[tool.setuptools_scm]
write_to = "conda_forge_webservices/_version.py"
write_to_template = "__version__ = '{version}'\n"

[tool.ruff]
target-version = "py310"
line-length = 88
Expand Down
29 changes: 29 additions & 0 deletions scripts/compute_next_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import datetime
import subprocess

# get the current date for tagging below
now = datetime.datetime.utcnow()

# get the most recent tag
res = subprocess.run(
["git", "describe", "--tags", "--abbrev=0"],
capture_output=True,
text=True,
)

if res.returncode != 0:
# no tags so compute the first version
new_version = f"{now.year}.{now.month}.0"
else:
# we have a tag so bump
curr_version = res.stdout.strip()

# figure out if we bump the major, minor or patch version
major_minor, patch = curr_version.rsplit(".", 1)
now_major_minor = f"{now.year}.{now.month}"
if major_minor == now_major_minor:
new_version = f"{major_minor}.{int(patch) + 1}"
else:
new_version = f"{now_major_minor}.0"

print(new_version, flush=True)
16 changes: 16 additions & 0 deletions scripts/release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os
import sys

import github

tag = sys.argv[1]
gh = github.Github(auth=github.Auth.Token(os.environ["GITHUB_TOKEN"]))
repo = gh.get_repo("regro/cf-scripts")

repo.create_git_release(
tag=tag,
name=tag,
draft=False,
prerelease=False,
generate_release_notes=True,
)

0 comments on commit 5ed3d91

Please sign in to comment.