最有效GitHub Action 创建Release

实战

weilining/HostlocAutoGetPoints: 腾讯云函数和GitHub Action测试通过

GitHub Action

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: CI

on:
push:
# Sequence of patterns matched against refs/tags
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout source
uses: actions/checkout@v1
- name: Build normal
run: |

zip -r mjjscf.zip ./*
- name: Create Release
id: create_release
uses: monkeyWie/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

- name: Upload Release normal windows
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./mjjscf.zip
asset_name: normal-${{ steps.create_release.outputs.tag }}-mjjscf.zip
asset_content_type: application/zip

脚本

1
2
3
4
5
6
7
8
9
10
11
12
git rm -r --cached .
git add .
git commit -m "main"
git pull origin main
git push origin main
# 创建tag名为v1.0.8,并添加描述
git tag -a "v1.0.8" -m '发布v1.0.8版本
修复了以下bug:
1. xxxxx
2. xxxxx'
# 把tag推到github上
git push --tags

参考文献

Github Actions 尝鲜 - SegmentFault 思否