ci: fix #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create a GitHub Release | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
component: | |
description: 'Component to release' | |
required: true | |
type: choice | |
default: maa-cli | |
options: | |
- maa-cli | |
- maa-run | |
- maa-sys | |
commit: | |
description: 'Commit to release' | |
required: false | |
type: string | |
default: main | |
jobs: | |
release-manual: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'workflow_dispatch' | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.inputs.commit }} | |
- name: Get name and version | |
id: vars | |
run: | | |
component=${{ github.event.inputs.component }} | |
tag_name=$(echo $component | sed -e 's/-/_/g') | |
version=$(yq -oy ".package.version" $component/Cargo.toml) | |
echo "name=$component $version" >> $GITHUB_OUTPUT | |
echo "tag_name=$tag_name-v$version" >> $GITHUB_OUTPUT | |
- name: Create Tag | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git tag ${{ steps.vars.outputs.tag_name }} ${{ github.event.inputs.commit }} | |
git push origin ${{ steps.vars.outputs.tag_name }} | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: ${{ steps.vars.outputs.name }} | |
tag_name: ${{ steps.vars.outputs.tag_name }} | |
generate_release_notes: true | |
release-auto: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && | |
contains(github.event.head_commit.message, '[release ') | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Get name and version | |
id: vars | |
run: | | |
component=$(echo ${{ github.event.head_commit.message }} | sed -e 's/.*\[release \(.*\)\].*/\1/') | |
tag_name=$(echo $component | sed -e 's/-/_/g') | |
version=$(yq -oy ".package.version" $component/Cargo.toml) | |
echo "name=$component $version" >> $GITHUB_OUTPUT | |
echo "tag_name=$tag_name-v$version" >> $GITHUB_OUTPUT | |
- name: Create Tag | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git tag ${{ steps.vars.outputs.tag_name }} | |
git push origin ${{ steps.vars.outputs.tag_name }} | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: ${{ steps.vars.outputs.name }} | |
tag_name: ${{ steps.vars.outputs.tag_name }} | |
generate_release_notes: true |