mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +01:00
ci: create publish release workflow (#9150)
* ci: create publish release workflow * test: fix tests for formatTag * ci(publish-release): fix string concat * ci: release action runs with tag as source * ci(publish-release): no longer testing --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
39
.github/workflows/publish-release.yml
vendored
Normal file
39
.github/workflows/publish-release.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
name: Publish Release
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [released]
|
||||||
|
jobs:
|
||||||
|
npm-publish:
|
||||||
|
name: npm publish
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||||
|
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
||||||
|
if: github.repository_owner == 'discordjs'
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install node.js v16
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16
|
||||||
|
registry-url: https://registry.npmjs.org/
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
uses: ./packages/actions/src/yarnCache
|
||||||
|
|
||||||
|
- name: Build dependencies
|
||||||
|
run: yarn build
|
||||||
|
|
||||||
|
- name: Extract package and semver from tag
|
||||||
|
id: extract-tag
|
||||||
|
uses: ./packages/actions/src/formatTag
|
||||||
|
with:
|
||||||
|
tag: ${{ github.ref_name }}
|
||||||
|
|
||||||
|
- name: Publish package
|
||||||
|
run: |
|
||||||
|
yarn workspace ${{ steps.extract-tag.outputs.subpackage == 'true' && '@discordjs/' || '' }}${{ steps.extract-tag.outputs.package }} npm publish
|
||||||
|
env:
|
||||||
|
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
||||||
@@ -3,16 +3,24 @@ import { formatTag } from '../src/index.js';
|
|||||||
|
|
||||||
describe('Format Tag', () => {
|
describe('Format Tag', () => {
|
||||||
test('GIVEN tag with a prefix THEN format tag to not contain the prefix', () => {
|
test('GIVEN tag with a prefix THEN format tag to not contain the prefix', () => {
|
||||||
expect(formatTag('@discordjs/rest@0.4.0')).toEqual({ package: 'rest', semver: '0.4.0' });
|
expect(formatTag('@discordjs/rest@0.4.0')).toEqual({ isSubpackage: true, package: 'rest', semver: '0.4.0' });
|
||||||
expect(formatTag('@discordjs/collection@0.6.0')).toEqual({ package: 'collection', semver: '0.6.0' });
|
expect(formatTag('@discordjs/collection@0.6.0')).toEqual({
|
||||||
expect(formatTag('@discordjs/proxy@0.1.0')).toEqual({ package: 'proxy', semver: '0.1.0' });
|
isSubpackage: true,
|
||||||
expect(formatTag('@discordjs/builders@0.13.0')).toEqual({ package: 'builders', semver: '0.13.0' });
|
package: 'collection',
|
||||||
expect(formatTag('@discordjs/voice@0.9.0')).toEqual({ package: 'voice', semver: '0.9.0' });
|
semver: '0.6.0',
|
||||||
|
});
|
||||||
|
expect(formatTag('@discordjs/proxy@0.1.0')).toEqual({ isSubpackage: true, package: 'proxy', semver: '0.1.0' });
|
||||||
|
expect(formatTag('@discordjs/builders@0.13.0')).toEqual({
|
||||||
|
isSubpackage: true,
|
||||||
|
package: 'builders',
|
||||||
|
semver: '0.13.0',
|
||||||
|
});
|
||||||
|
expect(formatTag('@discordjs/voice@0.9.0')).toEqual({ isSubpackage: true, package: 'voice', semver: '0.9.0' });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('GIVEN tag with no prefix THEN return tag', () => {
|
test('GIVEN tag with no prefix THEN return tag', () => {
|
||||||
expect(formatTag('13.5.1')).toEqual({ package: 'discord.js', semver: '13.5.1' });
|
expect(formatTag('13.5.1')).toEqual({ isSubpackage: false, package: 'discord.js', semver: '13.5.1' });
|
||||||
expect(formatTag('13.7.0')).toEqual({ package: 'discord.js', semver: '13.7.0' });
|
expect(formatTag('13.7.0')).toEqual({ isSubpackage: false, package: 'discord.js', semver: '13.7.0' });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('GIVEN no or invalid tag THEN return null', () => {
|
test('GIVEN no or invalid tag THEN return null', () => {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ export function formatTag(tag: string) {
|
|||||||
|
|
||||||
if (parsed?.groups) {
|
if (parsed?.groups) {
|
||||||
return {
|
return {
|
||||||
|
isSubpackage: typeof parsed.groups.package === 'string',
|
||||||
package: parsed.groups.package ?? 'discord.js',
|
package: parsed.groups.package ?? 'discord.js',
|
||||||
semver: parsed.groups.semver,
|
semver: parsed.groups.semver,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const tag = getInput('tag', { required: true });
|
|||||||
const parsed = formatTag(tag);
|
const parsed = formatTag(tag);
|
||||||
|
|
||||||
if (parsed) {
|
if (parsed) {
|
||||||
|
setOutput('subpackage', parsed.isSubpackage);
|
||||||
setOutput('package', parsed.package);
|
setOutput('package', parsed.package);
|
||||||
setOutput('semver', parsed.semver);
|
setOutput('semver', parsed.semver);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user