-
Notifications
You must be signed in to change notification settings - Fork 6
71 lines (68 loc) · 2.54 KB
/
release.yml
File metadata and controls
71 lines (68 loc) · 2.54 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: release
on:
# zizmor: ignore[dangerous-triggers] -- branchesで制限済み、信頼できない入力は使用していない
workflow_run:
workflows: [check]
types: [completed]
branches: [master, main]
permissions: {}
jobs:
release:
name: release
runs-on: ubuntu-24.04
permissions:
contents: write # タグ作成のため
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
if: github.event.workflow_run.conclusion == 'success'
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
ref: "${{ github.event.workflow_run.head_sha }}"
persist-credentials: false
fetch-depth: 0 # タグの存在確認と作成に全履歴が必要
- name: Extract version from Emacs Lisp header
id: version
run: |
set -euo pipefail
# Emacs Lispパッケージヘッダの`;; Version:`からバージョンを抽出する。
VERSION=$(sed -n 's/^;; Version: *//p' auto-sudoedit.el | tr -d '[:space:]')
if [ -z "$VERSION" ]; then
echo "No version found in auto-sudoedit.el"
exit 1
elif ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$'; then
echo "Invalid semver format: $VERSION"
exit 1
else
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
fi
- name: Check if tag exists
id: check-tag
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
if git show-ref --verify --quiet "refs/tags/v$VERSION"; then
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Create tag
if: steps.check-tag.outputs.skip != 'true'
env:
VERSION: ${{ steps.version.outputs.version }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
gh auth setup-git
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v$VERSION" -m "Release v$VERSION"
git push origin "v$VERSION"
- name: Create GitHub Release
if: steps.check-tag.outputs.skip != 'true'
env:
VERSION: ${{ steps.version.outputs.version }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create "v$VERSION" --generate-notes