Skip to content

Commit a7bc3eb

Browse files
author
Victor Navarro
committed
feat: initial commit
0 parents  commit a7bc3eb

16 files changed

Lines changed: 21118 additions & 0 deletions

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/renovate.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": ["config:base"],
3+
"schedule": ["every month"]
4+
}

.github/workflows/publish.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Publish
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
ci:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- run: yarn install
12+
- uses: ./
13+
with:
14+
repo-token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Dependency directory
2+
node_modules
3+
4+
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
13+
# Diagnostic reports (https://nodejs.org/api/report.html)
14+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
15+
16+
# Runtime data
17+
pids
18+
*.pid
19+
*.seed
20+
*.pid.lock
21+
22+
# Directory for instrumented libs generated by jscoverage/JSCover
23+
lib-cov
24+
25+
# Coverage directory used by tools like istanbul
26+
coverage
27+
*.lcov
28+
29+
# nyc test coverage
30+
.nyc_output
31+
32+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
33+
.grunt
34+
35+
# Bower dependency directory (https://bower.io/)
36+
bower_components
37+
38+
# node-waf configuration
39+
.lock-wscript
40+
41+
# Compiled binary addons (https://nodejs.org/api/addons.html)
42+
build/Release
43+
44+
# Dependency directories
45+
jspm_packages/
46+
47+
# TypeScript v1 declaration files
48+
typings/
49+
50+
# TypeScript cache
51+
*.tsbuildinfo
52+
53+
# Optional npm cache directory
54+
.npm
55+
56+
# Optional eslint cache
57+
.eslintcache
58+
59+
# Optional REPL history
60+
.node_repl_history
61+
62+
# Output of 'npm pack'
63+
*.tgz
64+
65+
# Yarn Integrity file
66+
.yarn-integrity
67+
68+
# dotenv environment variables file
69+
.env
70+
.env.test
71+
72+
# parcel-bundler cache (https://parceljs.org/)
73+
.cache
74+
75+
# next.js build output
76+
.next
77+
78+
# nuxt.js build output
79+
.nuxt
80+
81+
# vuepress build output
82+
.vuepress/dist
83+
84+
# Serverless directories
85+
.serverless/
86+
87+
# FuseBox cache
88+
.fusebox/
89+
90+
# DynamoDB Local files
91+
.dynamodb/
92+
93+
# OS metadata
94+
.DS_Store
95+
Thumbs.db
96+
97+
# Ignore built ts files
98+
tests/runner/*
99+
lib/**/*
100+
101+
# Editors
102+
.vscode
103+
.idea

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2020 Pocket Studios, Inc. and contributors
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
13+
all 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
21+
THE SOFTWARE.

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<div align="center">
2+
<h1>☝ update-version</h1>
3+
<p>Update your files version field on new releases</p>
4+
</div>
5+
6+
## 🧠 Why
7+
8+
- Most actions related to version upgrade do it backwards:
9+
when you push a commit with version change in a specific branch a release is created.
10+
11+
- This action does the opposite: when you create a release the
12+
specified files will get updated with the new version, so you don't forget to update them.
13+
14+
This comes in handy when working with git workflows such as [trunk-base-development](https://trunkbaseddevelopment.com/) or [master-only](https://www.youtube.com/watch?v=MWz-9uyHP4s).
15+
16+
## 🚀 Usage
17+
18+
With the following example after creating a new release with tag `v2.0.1` on branch `release`,
19+
a new commit will appear in that same branch with both `package.json` and `app.yaml` updated
20+
with the version field to `2.0.1`.
21+
22+
```yaml
23+
name: Upgrade Version
24+
on:
25+
release:
26+
types: [published]
27+
28+
jobs:
29+
upgrade-version:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v2
33+
- uses: pocket-studios/action-update-version@v1
34+
with:
35+
files: 'package.json, app.yaml'
36+
version-regexp: '\d+.\d+.\d+'
37+
repo-token: ${{ secrets.GITHUB_TOKEN }}
38+
```
39+
40+
The action will fail if:
41+
- Both `repo-token` and `branch-name` are not supplied
42+
- The tag cannot be found by `octokit`
43+
- The regular expression cannot match the release tag
44+
- You specify a file with unsupported extension
45+
46+
47+
## ⚙ Inputs
48+
49+
By supplying the `repo-token` the commit will use the release information: author and branch.
50+
51+
You can change the branch commit target and the commit author if you want.
52+
53+
**Name**|**Description**|**Default**
54+
-----|-----|-----
55+
files|Comma separated list of files to update its version field|package.json
56+
version-regexp|Regular expression to match release tag name|\d+.\d+.\d+
57+
repo-token|GitHub token to get the release information in order to push to branch|`null`
58+
commit-message|Commit message for files update. The %version% will get substituted|ci: update version to v%version%
59+
spacing-level|Number of spaces for formatted files|`2`
60+
branch-name|Default branch name to push changes if not repo-token is provided|*Release target branch*
61+
author-name|Commit author name|*Release author name*
62+
author-email|Commit author email|*Release author email*
63+
64+
## 👋 Support
65+
66+
- Supported file extensions: `json`, `yaml` and `yml`. To add one simply submit a PR with a new parser on the `main.ts` file.

action.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Update Files Version Field
2+
description: Update your files version field on new releases
3+
author: Pocket Studios
4+
branding:
5+
color: blue
6+
icon: arrow-up-circle
7+
runs:
8+
using: 'node12'
9+
main: 'dist/index.js'
10+
inputs:
11+
files:
12+
required: false
13+
description: Comma separated list of files to update its version field
14+
default: package.json
15+
version-regexp:
16+
required: false
17+
description: Regex to match release tag name
18+
default: '\d+.\d+.\d+'
19+
author-name:
20+
required: false
21+
description: Commit author name
22+
author-email:
23+
required: false
24+
description: Commit author email
25+
branch-name:
26+
required: false
27+
description: Default branch name to push changes if not repo-token is provided
28+
repo-token:
29+
required: false
30+
description: GitHub token to get the latest release in order to push to branch
31+
commit-message:
32+
required: false
33+
description: Commit message for files update
34+
default: 'ci: update version to v%version%'
35+
spacing-level:
36+
required: false
37+
description: Spacing level for formatted files
38+
default: '2'

0 commit comments

Comments
 (0)