Skip to content

Commit

Permalink
Merge pull request #1 from DIG-Network/release/v1.1.1-alpha.0
Browse files Browse the repository at this point in the history
Release/v1.1.1 alpha.0
  • Loading branch information
MichaelTaylor3D authored Sep 9, 2024
2 parents 30e5e2b + 610bd45 commit 2c9ef2a
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 4 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/auto-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Auto Tag

on:
push:
branches:
- main

concurrency:
group: main-release-check

jobs:
release:
name: release
runs-on: ubuntu-latest
steps:
- name: Clean workspace
uses: Chia-Network/actions/clean-workspace@main

- name: Checkout current branch
uses: actions/checkout@v3
with:
# Need PACKAGE_ADMIN_PAT token so when the tag is created, the tag automation runs
token: ${{ secrets.GH_ACCESS_TOKEN }}
fetch-depth: 0

- name: Set Git identity
run: |
git config --local user.email "[email protected]"
git config --local user.name "Automation"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Extract version from package.json
run: |
VERSION=$(jq -r '.version' package.json)
echo "Extracted version: $VERSION"
# Set the version as an output for other steps to use
echo "VERSION=$VERSION" >> $GITHUB_ENV
if git tag --list | grep -q "^$VERSION$"; then
echo "Tag $VERSION already exists, nothing to do."
else
echo "Tag does not exist. Creating and pushing tag."
git tag $VERSION -m "Release $VERSION"
git push origin $VERSION
fi
shell: bash
52 changes: 52 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build and Publish to npm

on:
push:
tags:
- "**"

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
build-and-publish:
name: Build and Publish to npm
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18.x"

- name: Install Dependencies
run: npm ci

- name: Build Project
run: npm run build

- name: Extract Version and Determine Tag
id: extract-version
run: |
VERSION=$(jq -r '.version' package.json)
if [[ "$VERSION" == *"alpha"* ]]; then
TAG="alpha"
elif [[ "$VERSION" == *"beta"* ]]; then
TAG="beta"
else
TAG="latest"
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "TAG=$TAG" >> $GITHUB_ENV
- name: Publish to npm
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --tag ${{ env.TAG }} --access public
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
47 changes: 47 additions & 0 deletions .github/workflows/ensure-version-increment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This workflow runs on any PRs that are targeting main and ensures that the version in package.json is incremented
name: Check Version Increment

on:
pull_request:
branches:
- 'main'

concurrency:
# SHA is added to the end if on `main` to let all main workflows run
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == 'refs/heads/main' && github.sha || '' }}
cancel-in-progress: true

jobs:
check-version:
name: Check version increment
runs-on: ubuntu-latest
steps:
- uses: Chia-Network/actions/clean-workspace@main

- name: Checkout current branch
uses: actions/checkout@v3
with:
path: branch-repo

- name: Checkout main
uses: actions/checkout@v3
with:
ref: main
path: main-repo

- name: Check Versions
run: |
# Extract version from main branch's package.json
mainVersion=$(jq -r '.version' main-repo/package.json)
echo "Main version: $mainVersion"
# Extract version from current branch's package.json
branchVersion=$(jq -r '.version' branch-repo/package.json)
echo "Branch version: $branchVersion"
# Compare versions
if [ "$branchVersion" == "$mainVersion" ]; then
echo "Version in package.json on this branch is not incremented. Version must increment for a merge to main."
exit 1
fi
shell: bash
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [1.1.1-alpha.0](https://github.com/DIG-Network/dig-chia-sdk/compare/v1.1.0...v1.1.1-alpha.0) (2024-09-09)

## [1.1.0](https://github.com/DIG-Network/dig-chia-sdk/compare/v1.0.9...v1.1.0) (2024-09-09)


Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dig-sdk",
"version": "1.1.0",
"name": "@dignetwork/dig-sdk",
"version": "1.1.1-alpha.0",
"description": "",
"type": "commonjs",
"main": "./dist/index.js",
Expand All @@ -15,8 +15,7 @@
"start": "ts-node src/index.ts",
"server": "ts-node src/server.ts",
"test": "mocha -r ts-node/register tests.ts",
"release": "standard-version",
"postrelease": "npm run build && git push --follow-tags && npm publish"
"prepare-release": "bash ./scripts/release.sh"
},
"author": "",
"license": "ISC",
Expand Down
36 changes: 36 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# Check for uncommitted changes
if ! git diff-index --quiet HEAD --; then
echo "You have uncommitted changes. Please commit or stash them before running this script."
exit 1
fi

# Ensure we're on the develop branch
CURRENT_BRANCH=$(git branch --show-current)
if [ "$CURRENT_BRANCH" != "develop" ]; then
echo "You must be on the 'develop' branch to run this script."
exit 1
fi

# Run standard-version for version bumping
npx standard-version --prerelease alpha

# Extract the new version from package.json after bumping
NEW_VERSION=$(jq -r '.version' package.json)

# Create a new feature branch based on the new version
FEATURE_BRANCH="release/v$NEW_VERSION"
git checkout -b "$FEATURE_BRANCH"

# Commit changes
git add .
git commit -m "chore(release): bump version to $NEW_VERSION"
git push --set-upstream origin "$FEATURE_BRANCH"

# Notify the user about the feature branch
echo "Version bumped and committed on branch $FEATURE_BRANCH."

git checkout develop

echo "Release PR set to origin on branch $FEATURE_BRANCH."

0 comments on commit 2c9ef2a

Please sign in to comment.