Skip to content

Commit

Permalink
ci: update workflow with versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
WolverMinion committed Jan 18, 2023
1 parent b45288a commit 9cf90e9
Showing 1 changed file with 52 additions and 57 deletions.
109 changes: 52 additions & 57 deletions .github/workflows/ci-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,22 @@ name: "CI/CD for Go"
on: push

jobs:
# get-next-version:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: 19
# - run: npx semantic-release -e semantic-release-monorepo --dry-run
# id: get-next-version
# env:
# GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
# outputs:
# new-release-published: ${{ steps.get-next-version.outputs.new-release-published }}
# new-release-version: ${{ steps.get-next-version.outputs.new-release-version }}

get-next-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: "checkout"
uses: actions/checkout@v3
- name: "get branch name"
id: extract_branch_name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF##*/})"
- name: "setup node"
uses: actions/setup-node@v3
with:
node-version: 19
- name: Semantic Release
- name: "init npm"
run: npm init -y
- name: "semantic release - get next version"
id: get-next-version
uses: cycjimmy/semantic-release-action@v3
with:
Expand All @@ -38,41 +31,35 @@ jobs:
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'main',
'feat/workflow-build',
{
name: 'beta',
prerelease: true
},
{
name: 'alpha',
prerelease: true
}
'${{ steps.extract_branch_name.outputs.branch }}'
]
# You can specify specifying version range for the extra plugins if you prefer.
#extra_plugins: |
# @semantic-release/changelog
# @semantic-release/git
# @semantic-release/release-notes-generator
# @semantic-release/exec
env:
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
#GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: test
run: pwd && ls -la && set
# - run: npx semantic-release -e semantic-release-monorepo --dry-run
# id: get-next-version
# env:
# GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
outputs:
new-release-published: ${{ steps.get-next-version.outputs.new-release-published }}
new-release-version: ${{ steps.get-next-version.outputs.new-release-version }}
- 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-published == 'true'
needs:
- get-next-version
if: needs.get-next-version.outputs.new-release-version != ''
steps:
- uses: actions/checkout@v3

Expand All @@ -81,30 +68,38 @@ jobs:
with:
go-version: 1.19

- name: Test
shell: bash
run: |
chmod u+x test.sh
./test.sh
- name: Build
shell: bash
env:
APP_VERSION: ${{ env.NEXT_RELEASE_VERSION }}
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 }}
- name: Test
shell: bash
run: |
chmod u+x test.sh
./test.sh
release:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: "setup node"
uses: actions/setup-node@v3
with:
node-version: 19
- run: npm ci
- run: npx semantic-release
- 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
env:
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit 9cf90e9

Please sign in to comment.