name: Auto Release
on:
pull_request:
types: [closed]
branches:
- main
jobs:
auto-release:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
environment:
name: huginn
deployment: false
if: >-
github.event.pull_request.merged == true &&
github.event.pull_request.head.ref == 'update-github-languages' &&
github.repository == 'luxass/github-languages-rs' &&
(github.event.pull_request.user.login == 'luxass' || github.event.pull_request.user.login == 'huginn-watch[bot]')
steps:
- name: generate token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 id: app-token
with:
repositories: luxass/github-languages-rs
client-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
permission-contents: write
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
persist-credentials: true
- run: rustup default stable
- uses: taiki-e/install-action@d858f8113943481093e02986a7586a4819a3bfd6 with:
tool: just,cargo-edit
- name: create tag and release
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
set -euo pipefail
IFS='.' read -r MAJOR MINOR PATCH <<< "$(awk -F ' = ' '/^version = / {gsub(/"/, "", $2); print $2; exit}' Cargo.toml)"
NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
while IFS= read -r msg; do
if [[ "$msg" =~ ^feat ]]; then
NEW_VERSION="$MAJOR.$((MINOR + 1)).0"
break
fi
done < <(git log "$BASE_SHA..$HEAD_SHA" --format=%s)
git config user.email "273299945+huginn-watch[bot]@users.noreply.github.com"
git config user.name "huginn-watch[bot]"
just release "$NEW_VERSION"
git push && git push --tags