Skip to content

modify readme

modify readme #54

Workflow file for this run

name: Release Workflow
on:
push:
branches:
- main
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm install
- name: Install type definitions
run: npm install --save-dev @types/node @types/fs-extra
- name: Compile TypeScript
run: npx tsc
- name: Lint with eslint
run: npm run lint
- name: Run tests
run: npm run test
prepare-release:
runs-on: ubuntu-latest
needs: test
outputs:
new_tag: ${{ steps.set_git_tag.outputs.target_tag_name }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set target major and minor version
run: |
echo "target_major_minor_tag=v0.1.x" >> $GITHUB_ENV
- name: Get latest tag
id: getlatesttag
run: |
git fetch --prune --unshallow
echo "$(git tag --sort=creatordate | tail -n 1)" > CUR_TAG
echo "cur_tag=$(cat CUR_TAG)" >> $GITHUB_ENV
- name: Set release tag
id: set_release_tag
run: |
# Assuming target_major_minor_tag has a format like "vX.Y.x"
# Extract major and minor version for the target tag
TARGET_MAJOR_MINOR=${target_major_minor_tag%.*} # Removes ".x" to get vX.Y
# Extract major and minor for the current tag
CURRENT_MAJOR_MINOR=${cur_tag%.*} # Removes ".Z" to get vX.Y
# Compare the target and current tag
if [[ "$TARGET_MAJOR_MINOR" == "$CURRENT_MAJOR_MINOR" ]]; then
# Since the major.minor matches, find the latest patch version for the target major.minor and increment it
LATEST_PATCH=$(git tag | grep "^${TARGET_MAJOR_MINOR}\." | cut -d. -f3 | sort -n | tail -1)
NEW_TAG="${TARGET_MAJOR_MINOR}.$((LATEST_PATCH+1))"
else
# If the major.minor doesn't match, check if any tag exists with the TARGET_MAJOR_MINOR
if git tag | grep -q "^${TARGET_MAJOR_MINOR}\."; then
LATEST_PATCH=$(git tag | grep "^${TARGET_MAJOR_MINOR}\." | cut -d. -f3 | sort -n | tail -1)
NEW_TAG="${TARGET_MAJOR_MINOR}.$((LATEST_PATCH+1))"
else
# If no tag exists for the target major.minor, start patch version from 0
NEW_TAG="${TARGET_MAJOR_MINOR}.0"
fi
fi
echo "tag_name=$NEW_TAG" >> $GITHUB_ENV
- name: Use computed tag
run: |
echo "Next tag will be: ${{ env.tag_name }}"
- name: Push the new tag
id: set_git_tag
run: |
echo "${{ env.tag_name }}" > TARGET_TAG_NAME
cat TARGET_TAG_NAME
git tag $(cat TARGET_TAG_NAME)
git push origin $(cat TARGET_TAG_NAME)
echo "target_tag_name=${{ env.tag_name }}" >> $GITHUB_OUTPUT
- name: Create release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.tag_name }}
release_name: Release ${{ env.tag_name }}
draft: true
prerelease: false
build-and-release:
needs: prepare-release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build with pkg
run: |
npm i
npx tsc
npm install -g pkg
pkg . -t node18-linux-x64 --output ./oasfi-linux
pkg . -t node18-macos-x64 --output ./oasfi-macos
pkg . -t node18-win-x64 --output ./oasfi.exe
- name: Create GitHub Release and Upload binaries/source
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.prepare-release.outputs.new_tag }}
files: |
./oasys-csv-cli-linux,
./oasys-csv-cli-macos,
./oasys-csv-cli-win.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}