ci: better release

This commit is contained in:
Larvan2 2024-05-18 18:36:00 +08:00
parent 2b52809d2c
commit 56edd8f671

View File

@ -1,6 +1,10 @@
name: Build name: Build
on: on:
workflow_dispatch: workflow_dispatch:
inputs:
version:
description: "Tag version to release"
required: true
push: push:
paths-ignore: paths-ignore:
- "docs/**" - "docs/**"
@ -13,7 +17,6 @@ on:
pull_request_target: pull_request_target:
branches: branches:
- Alpha - Alpha
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
@ -138,13 +141,13 @@ jobs:
curl https://github.com/golang/go/commit/9e43850a3298a9b8b1162ba0033d4c53f8637571.diff | patch --verbose -R -p 1 curl https://github.com/golang/go/commit/9e43850a3298a9b8b1162ba0033d4c53f8637571.diff | patch --verbose -R -p 1
- name: Set variables - name: Set variables
if: ${{github.ref_name=='Alpha'}} if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' }}
run: echo "VERSION=alpha-$(git rev-parse --short HEAD)" >> $GITHUB_ENV run: echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
shell: bash shell: bash
- name: Set variables - name: Set variables
if: ${{github.ref_name=='' || github.ref_type=='tag'}} if: ${{ github.event_name != 'workflow_dispatch' && github.ref_name == 'Alpha' }}
run: echo "VERSION=$(git describe --tags)" >> $GITHUB_ENV run: echo "VERSION=alpha-$(git rev-parse --short HEAD)" >> $GITHUB_ENV
shell: bash shell: bash
- name: Set Time Variable - name: Set Time Variable
@ -277,7 +280,7 @@ jobs:
Upload-Prerelease: Upload-Prerelease:
permissions: write-all permissions: write-all
if: ${{ github.ref_type == 'branch' && !startsWith(github.event_name, 'pull_request') }} if: ${{ github.event_name != 'workflow_dispatch' && github.ref_type == 'branch' && !startsWith(github.event_name, 'pull_request') }}
needs: [build] needs: [build]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -328,20 +331,39 @@ jobs:
Upload-Release: Upload-Release:
permissions: write-all permissions: write-all
if: ${{ github.ref_type=='tag' }} if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' }}
needs: [build] needs: [build]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 ref: Meta
fetch-depth: '0'
fetch-tags: 'true'
- name: Get tags - name: Get tags
run: | run: |
echo "CURRENTVERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV echo "CURRENTVERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
git fetch --tags git fetch --tags
echo "PREVERSION=$(git describe --tags --abbrev=0 HEAD^)" >> $GITHUB_ENV echo "PREVERSION=$(git describe --tags --abbrev=0 HEAD)" >> $GITHUB_ENV
- name: Merge Alpha branch into Meta
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git fetch origin Alpha:Alpha
git merge Alpha
git push origin Meta
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Tag the commit
run: |
git tag ${{ github.event.inputs.version }}
git push origin ${{ github.event.inputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate release notes - name: Generate release notes
run: | run: |
@ -359,12 +381,11 @@ jobs:
working-directory: bin working-directory: bin
- name: Upload Release - name: Upload Release
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v2
if: ${{ success() }} if: ${{ success() }}
with: with:
tag_name: ${{ github.ref_name }} tag_name: ${{ github.event.inputs.version }}
files: bin/* files: bin/*
generate_release_notes: true
body_path: release.md body_path: release.md
Docker: Docker: