Skip to content

Commit

Permalink
Merge pull request #1 from DIG-Network/release/v0.0.1-alpha.2
Browse files Browse the repository at this point in the history
Release/v0.0.1 alpha.2
  • Loading branch information
MichaelTaylor3D authored Sep 9, 2024
2 parents 8dc23ff + 36916f3 commit de21de4
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 5 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
35 changes: 35 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

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.

### [0.0.1-alpha.2](https://github.com/DIG-Network/dig-cli/compare/v1.1.2...v0.0.1-alpha.2) (2024-09-09)


### Bug Fixes

* yargs scriptname ([2b8d27b](https://github.com/DIG-Network/dig-cli/commit/2b8d27baf9eeb5b792ec4d4654b9d080f745144e))

### [1.1.3](https://github.com/DIG-Network/dig-cli/compare/v1.1.2...v1.1.3) (2024-09-08)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dig-chia-cli",
"version": "1.1.3",
"version": "0.0.1-alpha.2",
"description": "",
"type": "commonjs",
"main": "./dist/index.js",
Expand All @@ -14,8 +14,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"
"release": "bash ./scripts/release.sh"
},
"author": "",
"license": "ISC",
Expand Down
37 changes: 37 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/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."

# Instructions for further actions (manual steps)
echo "Next steps:"
echo "- Review the changes in the feature branch."
echo "- Push the branch to the remote repository if necessary."

0 comments on commit de21de4

Please sign in to comment.