Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: major version tags #682

Merged
merged 21 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"overrides": [
{
"files": ["bin/set-version-output", "config/*.js"],
"files": ["bin/set-version-output.js", "bin/set-major-version-tag.js", "config/*.js"],
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
# our package version and our Node.js version.
- name: Retrieve version values
id: rdme-version
run: ./bin/set-version-output
run: ./bin/set-version-output.js

# Next, we use this output to do a few find/replaces!
- name: Find and replace Node.js version placeholders
Expand Down
10 changes: 5 additions & 5 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The next step is to push these changes to GitHub:

```sh
git push # pushes the code
git push --tags # pushes the tags
git push --tags -f # pushes the tags
```

Once the code and tags are pushed to GitHub, [create a new release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#creating-a-release) so the latest tag is surfaced in [the GitHub Marketplace listing](https://github.com/marketplace/actions/rdme-sync-to-readme).
Expand All @@ -30,14 +30,14 @@ Auto-generating release notes is sufficient, but I like to summarize the changes

## Publishing to `npm` :rocket:

Finally, publish the changes to `npm`. If you're publishing to the default [distribution tag](https://docs.npmjs.com/adding-dist-tags-to-packages) (i.e., `latest`), you can run the following:
Finally, publish the changes to `npm`. If you're publishing to a non-standard [distribution tag](https://docs.npmjs.com/adding-dist-tags-to-packages) for prelease purposes or otherwise (e.g., `alpha`, `beta`, `next`, etc.), you can run the following:

```sh
npm publish
npm publish --tag <tag>
```

If you're publishing to another [distribution tag](https://docs.npmjs.com/adding-dist-tags-to-packages) for prelease purposes or otherwise (e.g., `alpha`, `beta`, `next`, etc.), include the tag like so:
If you're publishing to the default [distribution tag](https://docs.npmjs.com/adding-dist-tags-to-packages) (i.e., `latest`), you can omit the `--tag` flag like so:

```sh
npm publish --tag <tag>
npm publish
```
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Once installed in your project, you can use the `npx` prefix (which is included
npx rdme openapi:validate [file]
```

To ensure you're getting the latest features and security updates, we recommend using a tool like [Dependabot](https://docs.github.com/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/about-dependabot-version-updates) to keep `rdme` (and your other dependencies) up-to-date.
To ensure you're getting the latest features and security updates, we recommend using a tool like [Dependabot](https://docs.github.com/code-security/dependabot/dependabot-version-updates/about-dependabot-version-updates) to keep `rdme` (and your other dependencies) up-to-date.

### Authentication

Expand Down Expand Up @@ -117,7 +117,7 @@ rdme openapi --github

This will run through the `openapi` command, ask you a few quick questions, and then automatically create a fully functional GitHub Actions workflow file for you. 🪄

You can see examples featuring the latest version in [our docs](https://docs.readme.com/docs/rdme#github-actions-examples). We recommend [configuring Dependabot to keep your actions up-to-date](https://docs.github.com/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/keeping-your-actions-up-to-date-with-dependabot).
You can see examples featuring the latest version in [our docs](https://docs.readme.com/docs/rdme#github-actions-examples). We recommend [configuring Dependabot to keep your actions up-to-date](https://docs.github.com/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot).

## Usage

Expand Down
6 changes: 3 additions & 3 deletions __tests__/cmds/docs/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`docs\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
kanadgupta marked this conversation as resolved.
Show resolved Hide resolved
with:
rdme: docs ./__tests__/__fixtures__/docs/new-docs --key=\${{ secrets.README_API_KEY }} --version=1.0.0
"
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`docs\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: docs ./__tests__/__fixtures__/docs/new-docs --key=\${{ secrets.README_API_KEY }} --version=1.0.0
"
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`docs\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: docs ./__tests__/__fixtures__/docs/new-docs --key=\${{ secrets.README_API_KEY }} --version=1.0.1
"
Expand Down
14 changes: 7 additions & 7 deletions __tests__/cmds/openapi/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`openapi\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: openapi ./__tests__/__fixtures__/ref-oas/petstore.json --key=\${{ secrets.README_API_KEY }} --version=1.0.0 --create
"
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`openapi\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: openapi ./__tests__/__fixtures__/ref-oas/petstore.json --key=\${{ secrets.README_API_KEY }} --version=1.0.1 --create
"
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`openapi\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: openapi ./__tests__/__fixtures__/ref-oas/petstore.json --key=\${{ secrets.README_API_KEY }} --id=1
"
Expand Down Expand Up @@ -158,7 +158,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`openapi\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: openapi ./__tests__/__fixtures__/ref-oas/petstore.json --key=\${{ secrets.README_API_KEY }} --id=1
"
Expand Down Expand Up @@ -199,7 +199,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`openapi\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: openapi ./__tests__/__fixtures__/ref-oas/petstore.json --key=\${{ secrets.README_API_KEY }} --id=1
"
Expand Down Expand Up @@ -240,7 +240,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`openapi\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: openapi petstore.json --key=\${{ secrets.README_API_KEY }} --id=1 --workingDirectory=./__tests__/__fixtures__/relative-ref-oas
"
Expand Down Expand Up @@ -281,7 +281,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`openapi\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: openapi ./__tests__/__fixtures__/ref-oas/petstore.json --key=\${{ secrets.README_API_KEY }} --id=spec2
"
Expand Down
8 changes: 4 additions & 4 deletions __tests__/cmds/openapi/__snapshots__/validate.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`openapi:validate\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: openapi:validate __tests__/__fixtures__/petstore-simple-weird-version.json
"
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`openapi:validate\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: openapi:validate petstore.json --workingDirectory=./__tests__/__fixtures__/relative-ref-oas
"
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`openapi:validate\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: openapi:validate __tests__/__fixtures__/petstore-simple-weird-version.json
"
Expand Down Expand Up @@ -142,7 +142,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`openapi:validate\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: openapi:validate __tests__/__fixtures__/petstore-simple-weird-version.json
"
Expand Down
4 changes: 2 additions & 2 deletions __tests__/helpers/get-gha-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export function before(writeFileSyncCb) {

process.env.TEST_RDME_CREATEGHA = 'true';

const spy = jest.spyOn(getPkgVersion, 'getPkgVersion');
spy.mockReturnValue(Promise.resolve('7.8.9'));
const spy = jest.spyOn(getPkgVersion, 'getMajorPkgVersion');
spy.mockReturnValue(Promise.resolve(7));
}

/**
Expand Down
32 changes: 16 additions & 16 deletions __tests__/lib/__snapshots__/createGHA.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`changelogs\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: changelogs ./changelogs --key=\${{ secrets.README_API_KEY }}
"
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`changelogs\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: changelogs ./changelogs/rdme.md --key=\${{ secrets.README_API_KEY }}
"
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`changelogs\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: changelogs ./changelogs --key=\${{ secrets.README_API_KEY }}
"
Expand Down Expand Up @@ -158,7 +158,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`changelogs\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: changelogs ./changelogs/rdme.md --key=\${{ secrets.README_API_KEY }}
"
Expand Down Expand Up @@ -199,7 +199,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`custompages\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: custompages ./custompages --key=\${{ secrets.README_API_KEY }}
"
Expand Down Expand Up @@ -240,7 +240,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`custompages\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: custompages ./custompages/rdme.md --key=\${{ secrets.README_API_KEY }}
"
Expand Down Expand Up @@ -281,7 +281,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`custompages\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: custompages ./custompages --key=\${{ secrets.README_API_KEY }}
"
Expand Down Expand Up @@ -322,7 +322,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`custompages\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: custompages ./custompages/rdme.md --key=\${{ secrets.README_API_KEY }}
"
Expand Down Expand Up @@ -363,7 +363,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`docs\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: docs --key=\${{ secrets.README_API_KEY }} --version=1.0.0
"
Expand Down Expand Up @@ -404,7 +404,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`docs\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: docs ./docs/rdme.md --key=\${{ secrets.README_API_KEY }} --version=1.0.0
"
Expand Down Expand Up @@ -445,7 +445,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`docs\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: docs --key=\${{ secrets.README_API_KEY }} --version=1.0.0
"
Expand Down Expand Up @@ -486,7 +486,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`docs\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: docs ./docs/rdme.md --key=\${{ secrets.README_API_KEY }} --version=1.0.0
"
Expand Down Expand Up @@ -527,7 +527,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`openapi\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: openapi petstore.json --key=\${{ secrets.README_API_KEY }} --id=spec_id
"
Expand Down Expand Up @@ -568,7 +568,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`openapi\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: openapi petstore.json --key=\${{ secrets.README_API_KEY }} --id=spec_id
"
Expand Down Expand Up @@ -605,7 +605,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`openapi:validate\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: openapi:validate petstore.json
"
Expand Down Expand Up @@ -642,7 +642,7 @@ jobs:
uses: actions/checkout@v3

- name: Run \`openapi:validate\` command 🚀
uses: readmeio/rdme@7.8.9
uses: readmeio/rdme@v7
with:
rdme: openapi:validate petstore.json
"
Expand Down
15 changes: 5 additions & 10 deletions __tests__/lib/createGHA.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@ import DocsCommand from '../../src/cmds/docs';
import OpenAPICommand from '../../src/cmds/openapi';
import OpenAPIValidateCommand from '../../src/cmds/openapi/validate';
import configstore from '../../src/lib/configstore';
import createGHA, {
getConfigStoreKey,
getGHAFileName,
getGitData,
getMajorRdmeVersion,
git,
} from '../../src/lib/createGHA';
import createGHA, { getConfigStoreKey, getGHAFileName, getGitData, git } from '../../src/lib/createGHA';
import { getMajorPkgVersion } from '../../src/lib/getPkgVersion';
import { after, before } from '../helpers/get-gha-setup';
import getGitRemoteMock from '../helpers/get-git-mock';
import ghaWorkflowSchema from '../helpers/github-workflow-schema.json';
Expand Down Expand Up @@ -130,7 +125,7 @@ describe('#createGHA', () => {

const repoRoot = process.cwd();

configstore.set(getConfigStoreKey(repoRoot), (await getMajorRdmeVersion()) - 1);
configstore.set(getConfigStoreKey(repoRoot), (await getMajorPkgVersion()) - 1);

return expect(createGHA('', cmd, command.args, opts)).resolves.toMatch(
'Your GitHub Actions workflow file has been created!'
Expand All @@ -153,7 +148,7 @@ describe('#createGHA', () => {
)
);

expect(configstore.get(getConfigStoreKey(repoRoot))).toBe(await getMajorRdmeVersion());
expect(configstore.get(getConfigStoreKey(repoRoot))).toBe(await getMajorPkgVersion());
});

it('should not run if not a repo', () => {
Expand All @@ -175,7 +170,7 @@ describe('#createGHA', () => {
it('should not run if user previously declined to set up GHA for current directory + pkg version', async () => {
const repoRoot = process.cwd();

configstore.set(getConfigStoreKey(repoRoot), await getMajorRdmeVersion());
configstore.set(getConfigStoreKey(repoRoot), await getMajorPkgVersion());

return expect(createGHA('success!', cmd, command.args, opts)).resolves.toBe('success!');
});
Expand Down
Loading