-
Notifications
You must be signed in to change notification settings - Fork 5
107 lines (95 loc) · 3.11 KB
/
Copy pathcicd.yml
File metadata and controls
107 lines (95 loc) · 3.11 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: CICD
on:
push:
branches: [main]
paths-ignore: ["**.md"]
pull_request:
paths-ignore: ["**.md"]
permissions:
contents: read
defaults:
run:
shell: bash
jobs:
check:
name: Run tests and checks
strategy:
fail-fast: false
matrix:
# prettier-ignore
include:
- { os: ubuntu-latest }
- { os: macos-latest }
runs-on: ${{ matrix.os }}
steps:
- name: Setup | Checkout
uses: actions/checkout@v4
- name: Post Setup | Show information
run: bash --version
- name: Check | Shellcheck
uses: ludeeus/action-shellcheck@master
with:
severity: error
additional_files: toggle-popup.tmux
- name: Check | Test suite
run: ./run_tests.sh
changelog:
name: Update changelog
needs: [check]
if: github.event_name == 'pull_request'
permissions:
contents: write # need to commit changes
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout
uses: actions/checkout@v4
with: { ref: "${{ github.head_ref }}" }
- name: Doc | Update changelog
run: |
sed -i \
-e 's/{{PRNUM}}/${{ github.event.number }}/g' \
-e "s/{{DATE}}/$(date -u +'%Y-%m-%d')/g" \
CHANGELOG.md
- name: Post Doc | Commit changes
uses: stefanzweifel/git-auto-commit-action@v6
with:
commit_message: "docs: expand variables in changelog"
commit_user_name: github-actions[bot]
commit_user_email: github-actions[bot]@users.noreply.github.com
commit_author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
# How to create a new GitHub release?
# 1. Create a release branch named "release/<tag>".
# 2. Open a PR from the branch, including the release note in the PR body.
# 3. Wait for the CI to create a draft release.
# 4. Publish the release when it's ready.
release:
name: Create GitHub release
needs: [check, changelog]
if: startsWith(github.head_ref, 'release/') && github.repository == 'loichyan/tmux-toggle-popup'
permissions:
contents: write # need to update release
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout
uses: actions/checkout@v4
- name: Setup | Configure
id: configure
run: |
echo tag="${GITHUB_HEAD_REF#release/}" >$GITHUB_OUTPUT
- name: Release | Create Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release_tag: ${{ steps.configure.outputs.tag }}
release_body: ${{ github.event.pull_request.body }}
run: |
if gh release view "$release_tag" >/dev/null; then
echo "update existing release $release_tag"
gh release edit "$release_tag" --notes="$release_body"
else
echo "create new release $release_tag"
gh release create "$release_tag" \
--target="$GITHUB_BASE_REF" \
--draft=true \
--title="${release_tag#v} ($(date -u +'%Y-%m-%d'))" \
--notes="$release_body"
fi