Skip to content

feat: add cmd repository sync #41

feat: add cmd repository sync

feat: add cmd repository sync #41

Workflow file for this run

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: "CI/CD for Go"
on: push
jobs:
get-next-version:
runs-on: ubuntu-latest
steps:
- name: "checkout"
uses: actions/checkout@v3
- name: "get branch name"
id: extract_branch_name
shell: bash
run: |
branch_name=$(git rev-parse --abbrev-ref HEAD)
echo "::set-output name=branch::$(echo ${branch_name})"
- name: "setup node"
uses: actions/setup-node@v3
with:
node-version: 19
- name: "init npm"
run: npm init -y
- name: "semantic release - get next version"
id: get-next-version
uses: cycjimmy/semantic-release-action@v3
with:
dry_run: true
#semantic_version: 20.0.2
# you can set branch for semantic-release older than v16.
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'${{ steps.extract_branch_name.outputs.branch }}'
]
env:
#GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: "check outputs and env"
run: |
echo "check the result from step `get-next-version`"
pwd
ls -la
set
echo """
new_release_published: ${{ steps.get-next-version.outputs.new_release_published }}
new_release_version: ${{ steps.get-next-version.outputs.new_release_version }}
new_release_major_version: ${{ steps.get-next-version.outputs.new_release_major_version }}
last_release_version: ${{ steps.get-next-version.outputs.last_release_version }}
"""
outputs:
new-release-published: ${{ steps.get-next-version.outputs.new_release_published }}
new-release-version: ${{ steps.get-next-version.outputs.new_release_version }}
build:
runs-on: ubuntu-latest
needs:
- get-next-version
if: needs.get-next-version.outputs.new-release-version != ''
steps:
- uses: actions/checkout@v3
- name: Set up Go environment
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Test
shell: bash
run: |
chmod u+x test.sh
./test.sh
- name: Build
shell: bash
env:
APP_VERSION: ${{ needs.get-next-version.outputs.new-release-version }}
run: |
echo "new release version: ${{ env.APP_VERSION }}"
chmod u+x build.sh
./build.sh ${{ env.APP_VERSION }}
release:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: "setup node"
uses: actions/setup-node@v3
with:
node-version: 19
- name: "init npm"
run: npm init -y
- name: "semantic release - create new release"
id: create-new-release
uses: cycjimmy/semantic-release-action@v3
with:
dry_run: false
#semantic_version: 20.0.2
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'main'
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}