Skip to content

Commit

Permalink
ci: config
Browse files Browse the repository at this point in the history
  • Loading branch information
mato533 committed Jun 17, 2023
1 parent 961b34e commit 3100d59
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 8 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/auto-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on:
pull_request:
branches:
- master
types: [closed]

jobs:
release:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com"
GH_USER: "github-actions[bot]"

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18.x"
cache: "yarn"
- run: git config --local user.email "${{ env.GH_EMAIL }}"
- run: git config --local user.name "${{ env.GH_USER }}"

- run: echo test
- run: echo "${{ github.event.pull_request.head.ref }}"

- run: echo "${{ github.event.pull_request.title }}"
- run: echo "APP_VERSION=$(echo ${{ github.event.pull_request.title }} |grep -o -E "([0-9]+\.){1}[0-9]+(\.[0-9]+)?" | head -n1)">>"${GITHUB_ENV}"
- run: |
APP_VERSION=$(echo ${{ github.event.pull_request.title }} |grep -o -E "([0-9]+\.){1}[0-9]+(\.[0-9]+)?" | head -n1)"
if [ ! -n "${APP_VERSION}" ]
then
exit 255
fi
- run: |
git tag "v${APP_VERSION}"
git push origin "v${APP_VERSION}"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test for develop
name: Pre-release tasks

on:
push:
Expand All @@ -9,12 +9,14 @@ on:

jobs:
pre-releas-task:
if: "${{ contains(github.event.head_commit.message, 'release: v') }}"
if: "${{ contains(github.event.head_commit.message, 'release:') }}"

runs-on: ubuntu-latest

env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com"
GH_USER: "github-actions[bot]"

steps:
- uses: actions/checkout@v3
Expand All @@ -25,8 +27,10 @@ jobs:

- run: echo "CHANGELOG">>./test.txt
- run: echo lint
- run: git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
- run: git config --local user.name "github-actions[bot]"
- run: echo "APP_VERSION=$(echo ${{ github.event.head_commit.message }} |grep -o -E "([0-9]+\.){1}[0-9]+(\.[0-9]+)?" | head -n1)">>"${GITHUB_ENV}"
- run: yarn version --new-version "${{ env.APP_VERSION }}" --no-git-tag-version
- run: git config --local user.email "${{ env.GH_EMAIL }}"
- run: git config --local user.name "${{ env.GH_USER }}"
- run: |
git add -N .
if ! git diff --exit-code --quiet
Expand All @@ -36,16 +40,24 @@ jobs:
git push
fi
- run: echo "APP_VERSION=$(echo ${{ github.event.head_commit.message }} |grep -o -E "(v[0-9]+\.){1}[0-9]+(\.[0-9]+)?" | head -n1)">>"${GITHUB_ENV}"
- run: echo "${{ env.APP_VERSION }}"
- run: echo "PR_TITLE=[RELEASE] ${{ env.APP_VERSION }}">>"${GITHUB_ENV}"
- run: echo "PR_TITLE=[RELEASE] v${{ env.APP_VERSION }}">>"${GITHUB_ENV}"
- run: echo "PR_COUNT=$(gh pr list -S '${{ env.PR_TITLE }}' in:title | wc -l)" >>"${GITHUB_ENV}"

- name: Create pull request
- name: Create pull request(for master)
if: ${{ env.PR_COUNT }} == 0
run: |
gh pr create \
-B master \
-t '${{ env.PR_TITLE }}' \
-a ${{ github.actor }} \
--body-file ./.github/RELEASE_WORKFLOW_TEMPLATE.md
- name: Create pull request(for develop)
if: ${{ env.PR_COUNT }} == 0
run: |
gh pr create \
-B develop \
-t '${{ env.PR_TITLE }}' \
-a ${{ github.actor }} \
--body-file ./.github/RELEASE_WORKFLOW_TEMPLATE.md
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ci-test-project",
"version": "1.0.1",
"version": "1.0.2",
"main": "index.js",
"repository": "https://github.com/mato533/test1.git",
"author": "mato533 <[email protected]>",
Expand Down

0 comments on commit 3100d59

Please sign in to comment.