Skip to content

Commit

Permalink
Merge pull request #26 from AntoinePrv/alpha
Browse files Browse the repository at this point in the history
Strong dev and pre release check
  • Loading branch information
AntoinePrv authored Dec 21, 2023
2 parents fb241b8 + 1096478 commit 946ea16
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ jobs:

- shell: bash -l {0}
id: fetch-release
run: python fetch_release.py ${{ github.event.inputs.version }}
run: |
python -m pip install packaging
python fetch_release.py ${{ github.event.inputs.version }}
- name: Release
uses: softprops/action-gh-release@v1
Expand Down
42 changes: 24 additions & 18 deletions fetch_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,45 @@
import requests
import rich
from pathlib import Path
from datetime import timedelta
import hashlib
import subprocess
import sys

from packaging.version import Version

cache = {}

known_subdirs = {
'linux-64',
'linux-ppc64le',
'linux-aarch64',
'osx-64',
'osx-arm64',
'win-64'
"linux-64",
"linux-ppc64le",
"linux-aarch64",
"osx-64",
"osx-arm64",
"win-64",
}


def get_all_tags_github():
url = "https://api.github.com/repos/mamba-org/micromamba-releases/tags"
r = requests.get(url, timeout=10)
r.raise_for_status()
tags = [t["name"] for t in r.json()]
return set(tags)


def extract_with_microamamba(archive, outdir):
subprocess.check_call(["micromamba", "package", "extract", str(archive), str(outdir)])
subprocess.check_call(
["micromamba", "package", "extract", str(archive), str(outdir)]
)


def set_output(name, value):
if os.environ.get("GITHUB_OUTPUT"):
with open(os.environ.get("GITHUB_OUTPUT"), 'a') as fh:
print(f'{name}={value}\n', file=fh)
with open(os.environ.get("GITHUB_OUTPUT"), "a") as fh:
print(f"{name}={value}\n", file=fh)

def get_micromamba(version='latest'):

def get_micromamba(version="latest"):
url = f"https://api.anaconda.org/release/conda-forge/micromamba/{version}"
existing_tags = get_all_tags_github()
print("Getting Anaconda.org API")
Expand All @@ -48,13 +55,13 @@ def get_micromamba(version='latest'):

if not known_subdirs.issubset(all_subdirs):
raise ValueError(f"Missing subdirs: {known_subdirs - all_subdirs}")

all_versions = set([d["version"] for d in rj["distributions"]])
assert(len(all_versions) == 1)
assert len(all_versions) == 1
version = all_versions.pop()

if "alpha" in version or "beta" in version:
print("Skipping alpha/beta version")
if (v := Version(version)).is_devrelease or v.is_prerelease:
print(f"Skipping dev and pre releases version '{version}'")
set_output("MICROMAMBA_NEW_VERSION", "false")
return

Expand All @@ -78,11 +85,10 @@ def get_micromamba(version='latest'):

dplat = d["attrs"]["subdir"]

# fetch file and extract it
# fetch file and extract it
r = requests.get(f"https:{url}", timeout=10)
r.raise_for_status()


path = Path(d["basename"])
if d["basename"].endswith(".tar.bz2"):
ext = ".tar.bz2"
Expand Down Expand Up @@ -138,4 +144,4 @@ def get_micromamba(version='latest'):
if len(sys.argv) > 1:
get_micromamba(sys.argv[1])
else:
get_micromamba()
get_micromamba()

0 comments on commit 946ea16

Please sign in to comment.