Skip to content

Commit 1b400b3

Browse files
committed
feat: initial release
0 parents  commit 1b400b3

22 files changed

+31004
-0
lines changed

.actrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-P ubuntu-latest=catthehacker/ubuntu:gh-20.04

.github/release-please-config.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"packages": {
4+
".": {
5+
"package-name": "",
6+
"release-type": "node",
7+
"extra-files": [
8+
{
9+
"type": "generic",
10+
"path": "README.md"
11+
}
12+
]
13+
}
14+
}
15+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "0.0.0"
3+
}

.github/workflows/build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Build
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Setup pnpm
16+
uses: pnpm/action-setup@v3
17+
- name: Setup Node
18+
uses: actions/setup-node@v4
19+
with:
20+
cache: pnpm
21+
- name: Install dependencies
22+
run: pnpm i --frozen-lockfile
23+
- name: Build
24+
run: pnpm build
25+
- name: Test
26+
run: pnpm test:run

.github/workflows/release.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
release-please:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
release_created: ${{ steps.release.outputs.release_created }}
18+
tag_name: ${{ steps.release.outputs.tag_name }}
19+
steps:
20+
- uses: googleapis/release-please-action@v4
21+
id: release
22+
with:
23+
token: ${{ secrets.GITHUB_TOKEN }}
24+
config-file: .github/release-please-config.json
25+
manifest-file: .github/release-please-manifest.json
26+
- uses: actions/checkout@v4
27+
- name: Tag Major & Minor
28+
if: ${{ steps.release.outputs.release_created }}
29+
run: |
30+
git config user.name github-actions[bot]
31+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
32+
git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/googleapis/release-please-action.git"
33+
34+
git tag -d v${{ steps.release.outputs.major }} || true
35+
git tag -d v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true
36+
37+
git push origin :v${{ steps.release.outputs.major }} || true
38+
git push origin :v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true
39+
40+
git tag -a v${{ steps.release.outputs.major }} -m "v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}"
41+
git tag -a v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} -m "v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}"
42+
43+
git push origin v${{ steps.release.outputs.major }}
44+
git push origin v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
node_modules
2+
coverage
3+
4+
logs
5+
*.log
6+
npm-debug.log*
7+
yarn-debug.log*
8+
yarn-error.log*
9+
lerna-debug.log*
10+
11+
.idea
12+
.vscode
13+
*.code-workspace

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Hammy
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
<h1 align="center">
2+
update-git-submodules (
3+
<a href="https://github.com/sgoudham/update-git-submodules/actions/workflows/build.yml"><img src="https://github.com/sgoudham/update-git-submodules/actions/workflows/build.yml/badge.svg"></a> )
4+
</h1>
5+
6+
This GitHub Action updates one or more git submodules in a repository to the
7+
latest tag. The primary use case for this action is to be used across the
8+
[Catppuccin](https://github.com/catppuccin) GitHub organisation, allowing
9+
repositories to update their submodules to the latest git tag instead of the
10+
latest commit.
11+
12+
### What it does
13+
14+
- It automatically parses `.gitmodules` and updates one or more submodules to the
15+
latest git tag.
16+
- It allows the user to specify which submodules to update.
17+
18+
### What it doesn't do
19+
20+
- It **does not** commit or push these changes back to the repository. Please
21+
see the "[Scenarios](#scenarios)" section for examples on how to do this.
22+
- It **does not** update submodules to the latest commit as I focused on tags for
23+
the initial release. I'd personally recommend using
24+
[Renovate](https://docs.renovatebot.com/modules/manager/git-submodules/) or
25+
equivalent if you'd like submodules to be updated to the latest commit. I will
26+
most likely add this functionality in the future.
27+
28+
## Usage
29+
30+
<!-- x-release-please-start-version -->
31+
32+
```yaml
33+
- uses: sgoudham/[email protected]
34+
with:
35+
# The path to the '.gitmodules' file.
36+
#
37+
# Defaults to '.gitmodules' in the root of the repository.
38+
gitmodulesPath: ""
39+
40+
# The git submodule(s) to update, the path should be the
41+
# same as the one specified in the '.gitmodules' file.
42+
#
43+
# Defaults to all submodules in the '.gitmodules' file.
44+
submodules: ""
45+
```
46+
47+
## Outputs
48+
49+
### Static Outputs
50+
51+
- `json`: A JSON array containing all the submodules that were updated.
52+
- `matrix`: A JSON array containing all the submodules that were updated,
53+
intended for use in a GitHub Actions matrix strategy.
54+
- `prBody`: A Markdown string containing a formatted table of all the submodules
55+
that were updated, intended for use in a pull request body.
56+
57+
### Dynamic Outputs
58+
59+
As well as the static outputs, this action will also output the following variables:
60+
61+
- `path`: The path to the submodule that was updated.
62+
- `url`: The GitHub URL of the submodule that was updated.
63+
- `previousTag`: The tag of the submodule before it was updated.
64+
- `latestTag`: The tag that the submodule was updated to.
65+
- `prBody`: A Markdown string intended for use in a pull request body.
66+
67+
These dynamic outputs will be prefixed with the submodule name (and the
68+
submodule path if the name is different to the path) followed by two hyphens
69+
(`--`).
70+
71+
For example, if the submodule is named `vscode-icons` and the path is
72+
`ports/vscode-icons`, the dynamic outputs will be:
73+
74+
- `vscode-icons--path`
75+
- `vscode-icons--url`
76+
- `vscode-icons--previousTag`
77+
- `vscode-icons--latestTag`
78+
- `vscode-icons--prBody`
79+
- `ports/vscode-icons--path`
80+
- `ports/vscode-icons--url`
81+
- `ports/vscode-icons--previousTag`
82+
- `ports/vscode-icons--latestTag`
83+
- `ports/vscode-icons--prBody`
84+
85+
## Scenarios
86+
87+
1. [Update one submodule and create one pull request](#update-one-submodule-and-create-one-pull-request)
88+
2. [Update multiple submodules and create one pull request](#update-multiple-submodules-and-create-one-pull-request)
89+
3. [Update multiple submodules and create multiple pull requests](#update-multiple-submodules-and-create-multiple-pull-requests)
90+
91+
### Update one submodule and create one pull request
92+
93+
`.gitmodules`
94+
95+
```ini
96+
[submodule "vscode-icons"]
97+
path = ports/vscode-icons
98+
url = https://github.com/catppuccin/vscode-icons.git
99+
```
100+
101+
`workflow.yml`
102+
103+
```yaml
104+
steps:
105+
- name: Checkout Repository
106+
uses: actions/checkout@v4
107+
with:
108+
submodules: "recursive"
109+
fetch-depth: 0
110+
111+
- name: Update Submodules
112+
id: submodules
113+
uses: "sgoudham/[email protected]"
114+
115+
- name: Create PR
116+
uses: peter-evans/create-pull-request@v6
117+
if: ${{ steps.submodules.outputs['vscode-icons--latestTag'] }}
118+
with:
119+
commit-message: "feat: update catppuccin/vscode-icons to ${{ steps.submodules.outputs['vscode-icons--latestTag'] }}"
120+
branch: "feat/update-vscode-icons-${{ steps.submodules.outputs['vscode-icons--latestTag'] }}"
121+
title: "feat: update catppuccin/vscode-icons submodule to ${{ steps.submodules.outputs['vscode-icons--latestTag'] }}"
122+
body: ${{ steps.submodules.outputs.prBody }}
123+
```
124+
125+
### Update multiple submodules and create one pull request
126+
127+
```yaml
128+
steps:
129+
- name: Checkout Repository
130+
uses: actions/checkout@v4
131+
with:
132+
submodules: "recursive"
133+
fetch-depth: 0
134+
135+
- name: Update Submodules
136+
id: submodules
137+
uses: "sgoudham/[email protected]"
138+
139+
- name: Create PR
140+
uses: peter-evans/create-pull-request@v6
141+
with:
142+
commit-message: "feat: update all submodules"
143+
branch: "feat/update-all-submodules"
144+
title: "feat: update all submodules"
145+
body: ${{ steps.submodules.outputs.prBody }}
146+
```
147+
148+
### Update multiple submodules and create multiple pull requests
149+
150+
`.gitmodules`
151+
152+
```ini
153+
[submodule "ports/nvim"]
154+
path = ports/nvim
155+
url = https://github.com/catppuccin/nvim.git
156+
[submodule "ports/mdBook"]
157+
path = ports/mdBook
158+
url = https://github.com/catppuccin/mdBook.git
159+
[submodule "ports/vscode-icons"]
160+
path = ports/vscode-icons
161+
url = https://github.com/catppuccin/vscode-icons.git
162+
```
163+
164+
`workflow.yml`
165+
166+
```yaml
167+
jobs:
168+
update-submodule:
169+
runs-on: ubuntu-latest
170+
strategy:
171+
matrix:
172+
submodule: [ports/nvim, ports/mdBook]
173+
steps:
174+
- name: Checkout Repository
175+
uses: actions/checkout@v4
176+
with:
177+
submodules: "recursive"
178+
fetch-depth: 0
179+
180+
- name: Update Submodules
181+
id: submodules
182+
uses: "sgoudham/[email protected]"
183+
with:
184+
submodules: ${{ matrix.submodule }}
185+
186+
- name: Create PR
187+
uses: peter-evans/create-pull-request@v6
188+
if: ${{ steps.submodules.outputs[format('{0}--latestTag', matrix.submodule)] }}
189+
with:
190+
commit-message: "feat: update ${{ matrix.submodule }} to ${{ steps.submodules.outputs[format('{0}--latestTag', matrix.submodule)] }}"
191+
branch: "feat/update-${{ matrix.submodule }}-${{ steps.submodules.outputs[format('{0}--latestTag', matrix.submodule)] }}"
192+
title: "feat: update ${{ matrix.submodule }} submodule to ${{ steps.submodules.outputs[format('{0}--latestTag', matrix.submodule)] }}"
193+
body: ${{ steps.submodules.outputs.prBody }}
194+
```
195+
196+
<details>
197+
<summary>Drop me down to view a version where multiple pull requests are created in the same job (not recommended!)</summary>
198+
199+
```yaml
200+
jobs:
201+
update-submodules:
202+
runs-on: ubuntu-latest
203+
env:
204+
nvim: "ports/nvim"
205+
mdBook: "ports/mdBook"
206+
207+
steps:
208+
- name: Checkout Repository
209+
uses: actions/checkout@v4
210+
with:
211+
submodules: "recursive"
212+
fetch-depth: 0
213+
214+
- name: Update Submodules
215+
id: submodules
216+
uses: "sgoudham/[email protected]"
217+
with:
218+
submodules: |
219+
${{ env.nvim }}
220+
${{ env.mdBook }}
221+
222+
- name: Parse Submodule Outputs
223+
id: tags
224+
run: |
225+
echo "nvimTag=${{ steps.submodules.outputs[format('{0}--latestTag', env.nvim)] }}" >> "$GITHUB_OUTPUT"
226+
echo 'nvimPrBody<<EOF' >> $GITHUB_OUTPUT
227+
echo "${{ steps.submodules.outputs[format('{0}--prBody', env.nvim)] }}" >> "$GITHUB_OUTPUT"
228+
echo 'EOF' >> $GITHUB_OUTPUT
229+
230+
echo "mdBookTag=${{ steps.submodules.outputs[format('{0}--latestTag', env.mdBook)] }}" >> "$GITHUB_OUTPUT"
231+
echo 'mdBookPrBody<<EOF' >> $GITHUB_OUTPUT
232+
echo "${{ steps.submodules.outputs[format('{0}--prBody', env.mdBook)] }}" >> "$GITHUB_OUTPUT"
233+
echo 'EOF' >> $GITHUB_OUTPUT
234+
235+
- name: PR for Neovim
236+
uses: peter-evans/create-pull-request@v6
237+
if: ${{ steps.tags.outputs.nvimTag }}
238+
with:
239+
add-paths: ${{ env.nvim }}
240+
commit-message: "feat: update catppuccin/nvim to ${{ steps.tags.outputs.nvimTag }}"
241+
branch: "feat/update-catppuccin-nvim-${{ steps.tags.outputs.nvimTag }}"
242+
title: "feat: update catppuccin/nvim submodule to ${{ steps.tags.outputs.nvimTag }}"
243+
body: ${{ steps.tags.outputs.nvimPrBody }}
244+
245+
- name: PR for mdBook
246+
uses: peter-evans/create-pull-request@v6
247+
if: ${{ steps.tags.outputs.mdBookTag }}
248+
with:
249+
add-paths: ${{ env.mdBook }}
250+
commit-message: "feat: update catppuccin/mdBook to ${{ steps.tags.outputs.mdBookTag }}"
251+
branch: "feat/update-catppuccin-mdBook-${{ steps.tags.outputs.mdBookTag }}"
252+
title: "feat: update catppuccin/mdBook submodule to ${{ steps.tags.outputs.mdBookTag }}"
253+
body: ${{ steps.tags.outputs.mdBookPrBody }}
254+
```
255+
256+
</details>
257+
258+
<!-- x-release-please-end -->
259+
260+
## License
261+
262+
[MIT](./LICENSE)

0 commit comments

Comments
 (0)