Skip to content
This repository has been archived by the owner on Jul 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #16 from luongngocminh/dev
Browse files Browse the repository at this point in the history
Chore: Added alpha release pipeline
  • Loading branch information
luongngocminh authored Nov 30, 2023
2 parents bfa30d0 + 952d9ce commit 7c165d5
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 35 deletions.
31 changes: 31 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name-template: 'v$RESOLVED_VERSION 🌈'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧰 Maintenance'
label: 'chore'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
template: |
## What's Changed
$CHANGES
51 changes: 51 additions & 0 deletions .github/workflows/publish-alpha.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Publish Alpha

on:
release:
types: [prereleased]

jobs:
setup:
permissions:
contents: none
runs-on: ubuntu-latest
outputs:
version: ${{ steps.trim.outputs.version }}
steps:
- id: trim
run: echo "version=${TAG:1}" >> $GITHUB_OUTPUT
env:
TAG: ${{ github.event.release.tag_name }}

publish:
runs-on: ubuntu-latest
needs: setup

steps:
- name: 'Checkout the repository'
uses: 'actions/checkout@v3'

- name: 'Setup Node.js and npm'
uses: './.github/actions/setup'

- name: 'Generate package.json'
run: npm run config:prerelease -- ${{ needs.setup.outputs.version }}

- name: 'Pack npm package'
run: npm pack

- name: 'Publish to npm'
run: npm publish --tag alpha --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Upload NPM package file
id: upload-npm-package-file
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.setup.outputs.version }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ format('8xff-atm0s-media-js-{0}.tgz', needs.setup.outputs.version) }}
asset_name: ${{ format('8xff-atm0s-media-js-{0}.tgz', needs.setup.outputs.version) }}
asset_content_type: application/gzip
4 changes: 1 addition & 3 deletions .github/workflows/publish-nightly.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Nighly publish to npm

on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch: {}
repository_dispatch:
types: [publish-nightly]
Expand All @@ -18,7 +16,7 @@ jobs:
uses: './.github/actions/setup'

- name: 'Generate nightly package.json'
run: npm run config:nightly
run: npm run config:prerelease -- nightly

- run: npm publish --tag nightly --access public
env:
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release Drafter

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read

jobs:
update_release_draft:
permissions:
contents: write # for release-drafter/release-drafter to create a github release
pull-requests: write # for release-drafter/release-drafter to add label to PR
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@8xff/atm0s-media-js",
"version": "0.1.0",
"version": "0.1.1",
"description": "Provide a intuitive way to interact with Atm0s Media Server in Vanilla Javascript",
"cdn": "dist/index.umd.js",
"main": "dist/index.js",
Expand Down Expand Up @@ -54,7 +54,7 @@
"lint:fix": "eslint \"*/**/*.{ts,js,json}\" --fix",
"build": "rollup --config ./rollup.config.mjs",
"prepublishOnly": "npm run doc && npm run lint && npm run test && npm run build",
"config:nightly": "node ./scripts/configureNightly.mjs"
"config:prerelease": "node ./scripts/configurePrerelease.mjs"
},
"repository": {
"type": "git",
Expand Down
30 changes: 0 additions & 30 deletions scripts/configureNightly.mjs

This file was deleted.

42 changes: 42 additions & 0 deletions scripts/configurePrerelease.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
/**
* A minimal description for a parsed package.json object.
* @typedef {{
name: string;
version: string;
}} PackageJson
*/

function main() {
// eslint-disable-next-line no-undef
const args = process.argv.slice(2);
if (args.length !== 1) {
throw new Error('Usage: node configurePrerelease.mjs <version>');
}

const inputVersion = args[0];
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const packageJson = JSON.parse(fs.readFileSync(path.join(rootDir, 'package.json'), 'utf-8'));

let version = inputVersion;

if (inputVersion.includes('nightly')) {
/** @type {PackageJson} */
const oldVersion = packageJson.version;
version = `${oldVersion}-nightly.${new Date().toISOString().slice(0, 10).replace(/-/g, '')}`;
}

const packageJsonNew = {
...packageJson,
version,
};

fs.writeFileSync(path.join(rootDir, 'package.json'), JSON.stringify(packageJsonNew, null, 2), 'utf-8');

// eslint-disable-next-line no-undef
console.log(`Created package.nightly.json with version ${version}`);
}

main();

0 comments on commit 7c165d5

Please sign in to comment.