Skip to content

Commit

Permalink
feat: update packages and pipelines (#28)
Browse files Browse the repository at this point in the history
Packages here updated and also pipeline now support versions on snapshot. Added to creation process of the monorepo.
  • Loading branch information
miguelramos authored Oct 25, 2022
1 parent 4f77fec commit aa0afd6
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 31 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,11 @@ If you run the cli from inside your workspace folder this parameters are resolve
Predefined actions were created when you created an workspace. This actions will trigger based on:
- Branch name as: feat/...
- Tag creation
- Snapshot

Also there one release that will put as npm package on github to be consume as that if you need.

The branch will create a snapshot artifact to be use for development needs. On tag will create the artifact for production.
Example of what runs on github action.

```bash
> sublime action --type branch --env "$NODE_ENV"
```
To create a snapshot, create a branch ```releases/snapshots``` and just follow the step of ```yarn changesets```. The pipeline will create an artifact with next version and sufixed with snapshot for testing purposes (v1.0.0-SNAPSHOT).

| Parameter | Description |
|---|---|
Expand Down
29 changes: 17 additions & 12 deletions cmd/templates/changeset-config.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
{
"$schema": "https://unpkg.com/@changesets/config@1.5.0/schema.json",
"changelog": [
"@changesets/changelog-github",
{ "repo": "{{ .Namespace }}" }
],
"commit": false,
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
"$schema": "https://unpkg.com/@changesets/config@2.2.0/schema.json",
"changelog": [
"@changesets/changelog-github",
{ "repo": "{{ .Namespace }}" }
],
"commit": false,
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": [],
"useCalculatedVersion": true,
"snapshot": {
"useCalculatedVersion": true,
"prereleaseTemplate": "{tag}-{commit}"
}
}
3 changes: 2 additions & 1 deletion cmd/templates/vite-config-lit.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { version } from './package.json';

module.exports = defineConfig({
define: {
Version: JSON.stringify(version)
Version: JSON.stringify(version),
global: 'globalThis'
},
build: {
lib: {
Expand Down
3 changes: 2 additions & 1 deletion cmd/templates/vite-config-solid.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { version } from './package.json';

module.exports = defineConfig({
define: {
Version: JSON.stringify(version)
Version: JSON.stringify(version),
global: 'globalThis'
},
build: {
lib: {
Expand Down
3 changes: 2 additions & 1 deletion cmd/templates/vite-config-typescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { version } from './package.json';

module.exports = defineConfig({
define: {
Version: JSON.stringify(version)
Version: JSON.stringify(version),
global: 'globalThis'
},
build: {
lib: {
Expand Down
3 changes: 2 additions & 1 deletion cmd/templates/vite-config-vue.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { version } from './package.json';

module.exports = defineConfig({
define: {
Version: JSON.stringify(version)
Version: JSON.stringify(version),
global: 'globalThis'
},
build: {
lib: {
Expand Down
1 change: 1 addition & 0 deletions cmd/templates/workflow-artifact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0

- name: Setup node
uses: actions/setup-node@v2
Expand Down
3 changes: 3 additions & 0 deletions cmd/templates/workflow-feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0

- name: Setup node
uses: actions/setup-node@v2
Expand All @@ -39,3 +40,5 @@ jobs:
tar -xf sublime-[[ .Version ]]-linux-amd64.tar.gz sublime
chmod +x sublime
./sublime action --type branch --env "$NODE_ENV"
rm -rf sublime-[[ .Version ]]-linux-amd64.tar.gz
rm -rf sublime
55 changes: 55 additions & 0 deletions cmd/templates/workflow-snapshot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build and Create Snapshots

on:
push:
branches:
- 'releases/snapshots'

env:
CI: true
NODE_ENV: "develop"

jobs:
feat-artifacts:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0

- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '16.x'

- name: Install dependencies
run: yarn

- name: Build
run: yarn build

- name: Setup CI Git User
run: |
git config --global user.name "[[ .Username ]]"
git config --global user.email "[[ .Email ]]"
cat << EOF > "$HOME/.npmrc"
//npm.pkg.github.com/:_authToken=$GITHUB_TOKEN
[[.Scope]]:registry=https://npm.pkg.github.com
EOF
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

- name: Create Snapshot
uses: changesets/action@v1
with:
version: yarn changeset version --snapshot SNAPSHOT
publish: yarn changeset publish --tag SNAPSHOT --no-git-tag
title: "chore(snapshot): Packages snapshots"
commit: "chore(snapshot): releasing snapshot preview"
createGithubReleases: false
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.GH_TOKEN }}
16 changes: 8 additions & 8 deletions cmd/templates/workspace-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
"release": "yarn changeset publish"
},
"devDependencies": {
"turbo": "^1.2.5",
"@changesets/changelog-github": "^0.4.2",
"@changesets/cli": "^2.20.0",
"@changesets/get-github-info": "^0.5.0",
"eslint": "^8.13.0",
"turbo": "^1.6.1",
"@changesets/changelog-github": "^0.4.7",
"@changesets/cli": "^2.25.0",
"@changesets/get-github-info": "^0.5.1",
"eslint": "^8.26.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-sort-destructure-keys": "^1.4.0",
"eslint-plugin-unicorn": "^42.0.0"
"eslint-plugin-unicorn": "^44.0.2"
},
"engines": {
"node": ">=16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

var (
Version string = "v0.1.7"
Version string = "v0.1.9"
BuildTime string = fmt.Sprintf("%d", time.Now().Unix())
)

Expand Down
15 changes: 15 additions & 0 deletions cmd/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ func (ctx *CreateWorkspace) Workflows() {
if err != nil {
ctx.CommandError(err.Error(), utils.ErrorInvalidTemplate)
}
snapshotYaml, err := FileTemplates.ReadFile("templates/workflow-snapshot.yaml")
if err != nil {
ctx.CommandError(err.Error(), utils.ErrorInvalidTemplate)
}

releaseYamlFile, err := os.Create(filepath.Join(ctx.WorkspaceDir, ".github/workflows/release.yaml"))
if err != nil {
Expand Down Expand Up @@ -319,6 +323,17 @@ func (ctx *CreateWorkspace) Workflows() {
ctx.CommandError(err.Error(), utils.ErrorInvalidTemplate)
}

snapshotYamlFile, err := os.Create(filepath.Join(ctx.WorkspaceDir, ".github/workflows/snapshot.yaml"))
if err != nil {
ctx.CommandError(err.Error(), utils.ErrorCreateFile)
}
_, err = snapshotYamlFile.WriteString(utils.ProcessString(string(snapshotYaml), &models.SnapshotsYamlFileProps{
Version: Version,
}, "[[", "]]"))
if err != nil {
ctx.CommandError(err.Error(), utils.ErrorInvalidTemplate)
}

config.DoneProgress()
}

Expand Down
4 changes: 4 additions & 0 deletions models/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ type ArtifactsYamlFileProps struct {
Version string
}

type SnapshotsYamlFileProps struct {
Version string
}

type ApiExtractorFileProps struct {
Name string
}
Expand Down

0 comments on commit aa0afd6

Please sign in to comment.