Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 88 additions & 75 deletions .github/workflows/publish_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,19 @@ jobs:
- name: Find NPM packages
id: find-npm-packages
run: |
cd typescript
PACKAGES=$(find . -name "package.json" \
-not -path "*/node_modules/*" \
-not -path "./package.json" \
-not -path "*/examples/*" \
-not -path "*/create-onchain-agent/templates/*" \
-not -path "*/dist/*" \
-exec dirname {} \; | tr '\n' ' ')
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT

- name: Update NPM package versions
run: |
cd typescript
for pkg in ${{ steps.find-npm-packages.outputs.packages }}; do
if [ -f "$pkg/package.json" ]; then
cd $pkg
Expand All @@ -84,6 +88,7 @@ jobs:

- name: Publish packages
run: |
cd typescript
for pkg in ${{ steps.find-npm-packages.outputs.packages }}; do
if [ -f "$pkg/package.json" ] && ! grep -q '"private": true' "$pkg/package.json"; then
cd $pkg && npm publish --tag nightly --provenance --access public
Expand Down Expand Up @@ -114,13 +119,15 @@ jobs:
- name: Find Python packages
id: find-python-packages
run: |
cd python
PACKAGES=$(find . -name "pyproject.toml" \
-not -path "*/examples/*" \
-exec dirname {} \; | tr '\n' ' ')
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT

- name: Update Python package versions
run: |
cd python
for pkg in ${{ steps.find-python-packages.outputs.packages }}; do
if [ -f "$pkg/pyproject.toml" ]; then
cd $pkg
Expand Down Expand Up @@ -155,6 +162,7 @@ jobs:

- name: Build and publish
run: |
cd python
for pkg in ${{ steps.find-python-packages.outputs.packages }}; do
if [ -f "$pkg/pyproject.toml" ] && ! grep -q "private = true" "$pkg/pyproject.toml"; then
cd $pkg
Expand All @@ -165,82 +173,87 @@ jobs:
fi
done

create-github-release:
needs: [prepare-nightly, publish-npm-nightly, publish-pypi-nightly]
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
release_id: ${{ steps.create_release.outputs.id }}
steps:
- uses: actions/checkout@v4
with:
ref: nightly
# create-github-release:
# needs: [prepare-nightly, publish-npm-nightly, publish-pypi-nightly]
# runs-on: ubuntu-latest
# permissions:
# contents: write
# outputs:
# release_id: ${{ steps.create_release.outputs.id }}
# steps:
# - uses: actions/checkout@v4
# with:
# ref: nightly

- name: Install Poetry
uses: snok/install-poetry@v1
# - name: Install Poetry
# uses: snok/install-poetry@v1

- name: Generate Release Notes
id: release_notes
run: |
TODAY=$(date +%Y%m%d)
TODAY_FORMATTED=$(date +%Y-%m-%d)
echo "TODAY=$TODAY" >> $GITHUB_OUTPUT
echo "TODAY_FORMATTED=$TODAY_FORMATTED" >> $GITHUB_OUTPUT

{
extract_unreleased() {
local file=$1 package=$2 version=$3
if [ -f "$file" ]; then
if [[ $package == @* ]]; then
local url="https://www.npmjs.com/package/$package"
[[ $version != "latest" ]] && url="$url/v/$version"
else
local url="https://pypi.org/project/$package"
[[ $version != "latest" ]] && url="$url/$version"
fi
echo "## [📦 $package]($url)"
echo ""
awk '/^## Unreleased$/{p=1;next}/^## /{p=0}p' "$file" | grep -v '^$' || echo "No unreleased changes"
echo ""
fi
}

for pkg in $(find . -name "package.json" -not -path "*/node_modules/*" -not -path "./typescript/package.json" -not -path "*/examples/*" -exec dirname {} \;); do
if [ -f "$pkg/package.json" ] && ! grep -q '"private": true' "$pkg/package.json"; then
PKG_NAME=$(node -p "require('$pkg/package.json').name")
CHANGELOG="$pkg/CHANGELOG.md"
extract_unreleased "$CHANGELOG" "$PKG_NAME" \
$(npm view "$PKG_NAME" versions --json | jq -r '.[]' | grep -E "nightly\.${TODAY}\.[0-9]$" | sort -V | tail -n1 || echo "latest")
fi
done

for pkg in $(find . -name "pyproject.toml" -not -path "*/examples/*" -exec dirname {} \;); do
if [ -f "$pkg/pyproject.toml" ] && ! grep -q "private = true" "$pkg/pyproject.toml"; then
cd $pkg
PKG_NAME=$(poetry version | cut -d' ' -f1)
cd - > /dev/null
CHANGELOG="$pkg/CHANGELOG.md"
extract_unreleased "$CHANGELOG" "$PKG_NAME" \
$(curl -s "https://pypi.org/pypi/$PKG_NAME/json" | jq -r '.releases | keys[]' | grep -E "\.dev${TODAY}[0-9]$" | sort -V | tail -n1 || echo "latest")
fi
done

} > release_notes.md
# - name: Generate Release Notes
# id: release_notes
# run: |
# TODAY=$(date +%Y%m%d)
# TODAY_FORMATTED=$(date +%Y-%m-%d)
# echo "TODAY=$TODAY" >> $GITHUB_OUTPUT
# echo "TODAY_FORMATTED=$TODAY_FORMATTED" >> $GITHUB_OUTPUT

echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT
cat release_notes.md >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# {
# extract_unreleased() {
# local file=$1 package=$2 version=$3
# if [ -f "$file" ]; then
# if [[ $package == @* ]]; then
# local url="https://www.npmjs.com/package/$package"
# [[ $version != "latest" ]] && url="$url/v/$version"
# else
# local url="https://pypi.org/project/$package"
# [[ $version != "latest" ]] && url="$url/$version"
# fi
# echo "## [📦 $package]($url)"
# echo ""
# awk '/^## Unreleased$/{p=1;next}/^## /{p=0}p' "$file" | grep -v '^$' || echo "No unreleased changes"
# echo ""
# fi
# }

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TODAY: ${{ steps.release_notes.outputs.TODAY }}
with:
tag_name: nightly-${{ env.TODAY }}
release_name: "🌙 Nightly Build ${{ steps.release_notes.outputs.TODAY_FORMATTED }}"
body: ${{ steps.release_notes.outputs.RELEASE_NOTES }}
draft: false
prerelease: true
# cd typescript
# for pkg in $(find . -name "package.json" -not -path "*/node_modules/*" -not -path "./typescript/package.json" -not -path "*/examples/*" -not -path "*/create-onchain-agent/templates/*" -not -path "*/dist/*" -exec dirname {} \;); do
# if [ -f "$pkg/package.json" ] && ! grep -q '"private": true' "$pkg/package.json"; then
# PKG_NAME=$(node -p "require('$pkg/package.json').name")
# CHANGELOG="$pkg/CHANGELOG.md"
# extract_unreleased "$CHANGELOG" "$PKG_NAME" \
# $(npm view "$PKG_NAME" versions --json | jq -r '.[]' | grep -E "nightly\.${TODAY}\.[0-9]$" | sort -V | tail -n1 || echo "latest")
# fi
# done

# cd - > /dev/null

# cd python
# for pkg in $(find . -name "pyproject.toml" -not -path "*/examples/*" -exec dirname {} \;); do
# if [ -f "$pkg/pyproject.toml" ] && ! grep -q "private = true" "$pkg/pyproject.toml"; then
# cd $pkg
# PKG_NAME=$(poetry version | cut -d' ' -f1)
# cd - > /dev/null
# CHANGELOG="$pkg/CHANGELOG.md"
# extract_unreleased "$CHANGELOG" "$PKG_NAME" \
# $(curl -s "https://pypi.org/pypi/$PKG_NAME/json" | jq -r '.releases | keys[]' | grep -E "\.dev${TODAY}[0-9]$" | sort -V | tail -n1 || echo "latest")
# fi
# done

# cd - > /dev/null
# } > release_notes.md

# echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT
# cat release_notes.md >> $GITHUB_OUTPUT
# echo "EOF" >> $GITHUB_OUTPUT

# - name: Create Release
# id: create_release
# uses: actions/create-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# TODAY: ${{ steps.release_notes.outputs.TODAY }}
# with:
# tag_name: nightly-${{ env.TODAY }}
# release_name: "🌙 Nightly Build ${{ steps.release_notes.outputs.TODAY_FORMATTED }}"
# body: ${{ steps.release_notes.outputs.RELEASE_NOTES }}
# draft: false
# prerelease: true