Skip to content

Commit 9091cd6

Browse files
authored
feat: first blood, should just work (un-ts#1)
1 parent d719b4f commit 9091cd6

31 files changed

+10685
-1
lines changed

Diff for: .changeset/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

Diff for: .changeset/config.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": [
4+
"@changesets/changelog-github",
5+
{
6+
"repo": "rx-ts/changesets-gitlab"
7+
}
8+
],
9+
"commit": false,
10+
"linked": [],
11+
"access": "restricted",
12+
"baseBranch": "main",
13+
"updateInternalDependencies": "minor",
14+
"ignore": []
15+
}

Diff for: .changeset/silver-shirts-move.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'changesets-gitlab': minor
3+
---
4+
5+
feat: first blood, should just work

Diff for: .codesandbox/ci.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"node": "14",
3+
"sandboxes": []
4+
}

Diff for: .commitlintrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "@1stg"
3+
}

Diff for: .eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lib
2+
!/.*.js

Diff for: .eslintrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "@1stg"
3+
}

Diff for: .github/FUNDING.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: [JounQin]
2+
open_collective: rxts

Diff for: .github/workflows/ci.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: CI
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
ci:
9+
name: Lint and Test with Node.js ${{ matrix.node }}
10+
strategy:
11+
matrix:
12+
node:
13+
- 12
14+
- 14
15+
- 16
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout Repo
19+
uses: actions/checkout@master
20+
21+
- name: Setup Node.js ${{ matrix.node }}
22+
uses: actions/setup-node@master
23+
with:
24+
node-version: ${{ matrix.node }}
25+
26+
- name: Link Yarn global binaries into PATH
27+
run: echo "$(yarn global bin)" >> $GITHUB_PATH
28+
29+
- name: Get yarn cache directory path
30+
id: yarn-cache-dir-path
31+
run: echo "::set-output name=dir::$(yarn cache dir)"
32+
33+
- uses: actions/cache@v2
34+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
35+
with:
36+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
37+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
38+
restore-keys: |
39+
${{ runner.os }}-yarn-
40+
41+
- name: Install Dependencies
42+
run: yarn --frozen-lockfile
43+
44+
- name: Build and Lint
45+
run: |
46+
yarn build
47+
yarn lint
48+
yarn typecov
49+
env:
50+
EFF_NO_LINK_RULES: true
51+
PARSER_NO_WATCH: true

Diff for: .github/workflows/cli.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: cli
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
name: cli
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout Repo
14+
uses: actions/checkout@master
15+
with:
16+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
17+
fetch-depth: 0
18+
19+
- name: Setup Node.js 14.x
20+
uses: actions/setup-node@master
21+
with:
22+
node-version: 14.x
23+
24+
- name: Get yarn cache directory path
25+
id: yarn-cache-dir-path
26+
run: echo "::set-output name=dir::$(yarn cache dir)"
27+
28+
- uses: actions/cache@v2
29+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
30+
with:
31+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
32+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
33+
restore-keys: |
34+
${{ runner.os }}-yarn-
35+
36+
- name: Install Dependencies
37+
# https://github.com/atlassian/changesets/issues/246
38+
run: |
39+
yarn --frozen-lockfile
40+
rm -rf .git/hooks/commit-msg
41+
42+
- name: Create Release Merge Request or Publish to npm
43+
id: changesets
44+
run: yarn cli
45+
env:
46+
CI_COMMIT_REF_NAME: ${{ secrets.CI_COMMIT_REF_NAME }}
47+
CI_PROJECT_ID: ${{ secrets.CI_PROJECT_ID }}
48+
GITLAB_HOST: ${{ secrets.GITLAB_HOST }}
49+
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
50+
GLOBAL_AGENT_HTTP_PROXY: ${{ secrets.GLOBAL_AGENT_HTTP_PROXY }}
51+
INPUT_PUBLISH: yarn release
52+
INPUT_COMMIT: 'chore: release package(s)'
53+
INPUT_TITLE: 'chore: release package(s)'

Diff for: .github/workflows/release.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout Repo
14+
uses: actions/checkout@master
15+
with:
16+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
17+
fetch-depth: 0
18+
19+
- name: Setup Node.js 14.x
20+
uses: actions/setup-node@master
21+
with:
22+
node-version: 14.x
23+
24+
- name: Get yarn cache directory path
25+
id: yarn-cache-dir-path
26+
run: echo "::set-output name=dir::$(yarn cache dir)"
27+
28+
- uses: actions/cache@v2
29+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
30+
with:
31+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
32+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
33+
restore-keys: |
34+
${{ runner.os }}-yarn-
35+
36+
- name: Install Dependencies
37+
run: yarn --frozen-lockfile
38+
39+
- name: Create Release Pull Request or Publish to npm
40+
id: changesets
41+
uses: changesets/action@master
42+
with:
43+
# This expects you to have a script called release which does a build for your packages and calls changeset publish
44+
publish: yarn release
45+
commit: 'chore: release package(s)'
46+
title: 'chore: release package(s)'
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Diff for: .gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
lib
2+
node_modules
3+
.env
4+
.type-coverage
5+
*.log

Diff for: .lintstagedrc.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('@1stg/lint-staged')

Diff for: .prettierrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"@1stg/prettier-config"

Diff for: .remarkrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"settings": {
3+
"listItemIndent": 1,
4+
"tightDefinitions": true
5+
},
6+
"plugins": [
7+
"@1stg/remark-config"
8+
]
9+
}

Diff for: .renovaterc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": [
3+
"@1stg"
4+
]
5+
}

Diff for: .simple-git-hooks.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('@1stg/simple-git-hooks')

Diff for: README.md

+109-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,110 @@
11
# changesets-gitlab
2-
GitLab CI cli for [changesets](https://github.com/atlassian/changesets) like its [GitHub Action](https://github.com/changesets/action).
2+
3+
GitLab CI cli for [changesets](https://github.com/atlassian/changesets) like its [GitHub Action](https://github.com/changesets/action), it creates a pull request with all of the package versions updated and changelogs updated and when there are new changesets on master, the PR will be updated. When you're ready, you can merge the pull request and you can either publish the packages to npm manually or setup the action to do it for you.
4+
5+
## Usage
6+
7+
### Inputs
8+
9+
> Environment valuables starts with `INPUT_`, case insensitive
10+
11+
- publish - The command to use to build and publish packages
12+
- version - The command to update version, edit CHANGELOG, read and delete changesets. Default to `changeset version` if not provided
13+
- commit - The commit message to use. Default to `Version Packages`
14+
- title - The pull request title. Default to `Version Packages`
15+
16+
### Outputs
17+
18+
- published - A boolean value to indicate whether a publishing is happened or not
19+
- publishedPackages - A JSON array to present the published packages. The format is `[{"name": "@xx/xx", "version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}]`
20+
21+
### Example workflow
22+
23+
#### Without Publishing
24+
25+
Create a file at `.gitlab-ci.yml` with the following content.
26+
27+
```yml
28+
stages:
29+
- release
30+
31+
before_script: yarn --frozen-lockfile
32+
33+
release:
34+
image: node:lts-alpine
35+
only: main
36+
script: changesets-gitlab
37+
```
38+
39+
#### With Publishing
40+
41+
Before you can setup this action with publishing, you'll need to have an [npm token](https://docs.npmjs.com/creating-and-viewing-authentication-tokens) that can publish the packages in the repo you're setting up the action for and doesn't have 2FA on publish enabled ([2FA on auth can be enabled](https://docs.npmjs.com/about-two-factor-authentication)). You'll also need to [add it as a secret on your GitHub repo](https://help.github.com/en/articles/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables) with the name `NPM_TOKEN`. Once you've done that, you can create a file at `.github/workflows/release.yml` with the following content.
42+
43+
```yml
44+
stages:
45+
- release
46+
47+
before_script: yarn --frozen-lockfile
48+
49+
release:
50+
image: node:lts-alpine
51+
only: main
52+
script: changesets-gitlab
53+
variables:
54+
INPUT_PUBLISH: yarn release
55+
```
56+
57+
By default the GitHub Action creates a `.npmrc` file with the following content:
58+
59+
```sh
60+
//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}
61+
```
62+
63+
However, if a `.npmrc` file is found, the GitHub Action does not recreate the file. This is useful if you need to configure the `.npmrc` file on your own.
64+
For example, you can add a step before running the Changesets GitHub Action:
65+
66+
```yml
67+
script: |
68+
cat << EOF > "$HOME/.npmrc"
69+
70+
//registry.npmjs.org/:_authToken=$NPM_TOKEN
71+
EOF
72+
```
73+
74+
#### With version script
75+
76+
If you need to add additional logic to the version command, you can do so by using a version script.
77+
78+
If the version script is present, this action will run that script instead of `changeset version`, so please make sure that your script calls `changeset version` at some point. All the changes made by the script will be included in the PR.
79+
80+
```yml
81+
stages:
82+
- release
83+
84+
before_script: yarn --frozen-lockfile
85+
86+
release:
87+
image: node:lts-alpine
88+
only: main
89+
script: changesets-gitlab
90+
variables:
91+
INPUT_VERSION: yarn version
92+
```
93+
94+
#### With Yarn 2 / Plug'n'Play
95+
96+
If you are using [Yarn Plug'n'Play](https://yarnpkg.com/features/pnp), you should use a custom `version` command so that the action can resolve the `changeset` CLI:
97+
98+
```yml
99+
stages:
100+
- release
101+
102+
before_script: yarn --frozen-lockfile
103+
104+
release:
105+
image: node:lts-alpine
106+
only: main
107+
script: changesets-gitlab
108+
variables:
109+
INPUT_VERSION: yarn changeset version
110+
```

0 commit comments

Comments
 (0)