Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/scripts/create_pr_body.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,4 @@ echo "

这个PR是发布工作流自动创建的: https://github.com/$REPOSITORY/actions/runs/$RUN_ID。
我已经修改了版本号在这个commit: $COMMIT_ID。

合并这个PR将会创建一个GitHub release。
"
86 changes: 65 additions & 21 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@

# Create release branch from master or hotfix
name: Create release branch
on:
workflow_dispatch:
inputs:
next_version:
description: 'Version of next development iteration on master (ie 1.1.0)'
required: false

jobs:
create-release:
prepare-create:
runs-on: ubuntu-latest
if: github.ref_name == 'master' || startsWith(github.ref_name,'hotfix-')
outputs:
RELEASE_VERSION: ${{ steps.get-version.outputs.RELEASE_VERSION }}
VERSION_FILE: ${{ steps.get-version.outputs.VERSION_FILE }}
steps:
- uses: actions/checkout@v2
- name: Get version
id: get-version
run: |
version_file=buildSrc/src/main/kotlin/Versions.kt
version=$(awk '/Version =/ {print $5}' $version_file |sed 's/\"//g' |sed 's/-SNAPSHOT//g')
echo "RELEASE_VERSION=$version" >> $GITHUB_ENV
echo "VERSION_FILE=$version_file" >> $GITHUB_ENV
echo "RELEASE_VERSION=$version" >> $GITHUB_OUTPUT
echo "VERSION_FILE=$version_file" >> $GITHUB_OUTPUT
create-release:
runs-on: ubuntu-latest
needs: prepare-create
env:
RELEASE_VERSION: ${{ needs.prepare-create.outputs.RELEASE_VERSION }}
VERSION_FILE: ${{ needs.prepare-create.outputs.VERSION_FILE }}
steps:
- uses: actions/checkout@v2
- name: Setup git configuration
run: |
git config user.name "DevOps Project Bot"
Expand All @@ -23,24 +40,51 @@ jobs:
- name: Version Bump
run: |
sed -i 's/${{ env.RELEASE_VERSION }}-SNAPSHOT/${{ env.RELEASE_VERSION }}/g' ${{ env.VERSION_FILE }}
- name: Commit version file
id: commit-version-file
- name: Commit version file -- release branch
run: |
git add ${{ env.VERSION_FILE }}
git commit --message "Prepare release ${{ env.RELEASE_VERSION }}"
echo "::set-output name=commit::$(git rev-parse HEAD)"
- name: Push new branch
- name: Push new release branch
run: git push origin release-${{ env.RELEASE_VERSION }}
- name: Create pull request into master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./.github/scripts/create_pr_body.sh \
${{ github.actor }} \
${{ github.repository }} \
${{ github.run_id }} \
${{ steps.commit-version-file.outputs.commit }} | \
gh pr create -B master -H release-${{ env.RELEASE_VERSION }} \
--title 'Release version ${{ env.RELEASE_VERSION }}' \
--reviewer ${{ github.actor }} \
--body-file -
create-develop:
runs-on: ubuntu-latest
needs: prepare-create
if: github.event.inputs.next_version != ''
env:
RELEASE_VERSION: ${{ needs.prepare-create.outputs.RELEASE_VERSION }}
NEXT_VERSION: ${{ github.event.inputs.next_version }}
VERSION_FILE: ${{ needs.prepare-create.outputs.VERSION_FILE }}
steps:
- uses: actions/checkout@v2
with:
ref: master
- name: Setup git configuration
run: |
git config user.name "DevOps Project Bot"
git config user.email "[email protected]"
- name: Create develop branch
run: git checkout -b develop-${{ env.NEXT_VERSION }}
- name: Version Bump
run: |
sed -i 's/${{ env.RELEASE_VERSION }}/${{ env.NEXT_VERSION }}/g' ${{ env.VERSION_FILE }}
- name: Commit version file -- develop branch
id: commit-version-file-master
run: |
git add ${{ env.VERSION_FILE }}
git commit --message "Prepare for next development iteration ${{ env.NEXT_VERSION }}"
echo "::set-output name=commit::$(git rev-parse HEAD)"
- name: Push new develop branch
run: git push origin develop-${{ env.NEXT_VERSION }}
- name: Create pull request into master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./.github/scripts/create_pr_body.sh \
${{ github.actor }} \
${{ github.repository }} \
${{ github.run_id }} \
${{ steps.commit-version-file-master.outputs.commit }} | \
gh pr create -B master -H develop-${{ env.NEXT_VERSION }} \
--title 'Update version ${{ env.NEXT_VERSION }}-SNAPSHOT' \
--reviewer ${{ github.actor }} \
--body-file -
30 changes: 0 additions & 30 deletions .github/workflows/publish-release.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build and Publish snapshot package
on:
push:
branches:
- develop
- master

jobs:
build:
Expand Down
50 changes: 36 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@

# Releases can only from release-** branch
name: Release
on:
pull_request:
branches:
- master
types:
- closed
# Releases can only be triggered via the action tab
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
# only merged pull requests that begin with 'release-' must trigger this job
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release-')
if: startsWith(github.ref_name,'release-')
outputs:
RELEASE_VERSION: ${{ steps.get-version.outputs.RELEASE_VERSION }}
steps:
- name: Get version
if: startsWith(github.event.pull_request.head.ref, 'release-')
id: get-version
run: |
branch_name="${{ github.event.pull_request.head.ref }}"
branch_name="${{ github.ref_name }}"
version=${branch_name#release-}
echo "RELEASE_VERSION=$version" >> $GITHUB_ENV
echo "RELEASE_VERSION=$version" >> $GITHUB_OUTPUT
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Setup git configuration
run: |
git config user.name "DevOps Project Bot"
git config user.email "[email protected]"
- name: Create tag
run: git tag v${{ env.RELEASE_VERSION }}
run: git tag v${{ env.RELEASE_VERSION }} -m "Release v${{ env.RELEASE_VERSION }}"
- name: Push git tag
run: git push origin v${{ env.RELEASE_VERSION }}
- name: Setup Docker
Expand All @@ -53,5 +52,28 @@ jobs:
tag_name: v${{ env.RELEASE_VERSION }}
release_name: v${{ env.RELEASE_VERSION }}
body_path: ${{ steps.generate-changelog.outputs.changelog_path }}
draft: true
prerelease: true
deploy-release:
runs-on: ubuntu-latest
needs: release
steps:
- uses: actions/checkout@v2
with:
ref: v${{ needs.release.outputs.RELEASE_VERSION }}
- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: 8
- name: Set up Node JS
uses: actions/setup-node@v2
with:
node-version: 14
- name: Build with Gradle
run: ./gradlew build
- name: Publish release package
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
run: ./gradlew publish