Skip to content

Commit

Permalink
Add GitHub action for next releases (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lotes authored Feb 18, 2025
1 parent 8a04e85 commit 869e166
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish
name: Publish `latest`

permissions:
id-token: write
Expand All @@ -9,7 +9,7 @@ on:

jobs:
publish:
name: Typir Publish
name: Typir Publish `latest`
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/publish-next.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish `next`

permissions:
id-token: write

on:
workflow_dispatch:

jobs:
publish:
name: Typir Publish `next`
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Build
shell: bash
run: |
npm ci
npm run clean
npm run build
- name: Test
if: success() || failure()
shell: bash
run: |
npm run test:run
- name: Version as `next` packages
shell: bash
run: |
npm run version:next --workspace=typir
npm run version:next --workspace=typir-langium
npm run version:dependencies
- name: Publish NPM Packages
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm run publish:next --provenance --workspace=typir
npm run publish:next --provenance --workspace=typir-langium
20 changes: 20 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Release Process

## `latest` releases

The release process is mostly automated and requires running only a few commands. After commiting, pushing, tagging and releasing the changes, a GitHub Action will publish all npm packages.

1. Pull the latest changes from the main branch
Expand All @@ -17,3 +19,21 @@ The release process is mostly automated and requires running only a few commands
```

7. Create a [GitHub release](https://github.com/TypeFox/typir/releases) from the new tag (this will trigger the Github Action and publish all artifacts automatically).


## `next` releases

The release process for `next` releases is different from the `latest` releases. We configured a GitHub action to publish the `next` packages. It has to be called manually (it is a `workflow_dispatch`). This will release the current state of `main`. Follow these steps to release a `next` version:

1. Go to the Actions tab of your repository.
2. On the left there is a list of workflow. Click the one the title "Publish `next`".
3. A blue ribbon will appear, stating `This workflow has a workflow_dispatch event trigger.`.
4. Click the button `Run workflow` from the ribbon.
5. A popup will appear, asking you for which branch you want to run the workflow. Select `main` and click the button `Run workflow`.

Hint: What happens behind the scene is:

1. the action calls `npm run version:next` for each workspace package
2. then it calls `npm run version:dependencies` to update the dependencies
3. then it calls `npm run publish:next` to publish the updated packages
4. the action discards everything, no changes will be committed or pushed
23 changes: 4 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"eslint": "~8.57.1",
"eslint-plugin-header": "~3.1.1",
"fs-extra": "^11.2.0",
"semver": "^7.7.1",
"shx": "~0.3.4",
"typescript": "~5.5.4",
"vitest": "~2.1.2"
Expand Down
5 changes: 3 additions & 2 deletions packages/typir-langium/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
"build": "tsc",
"watch": "tsc --watch",
"lint": "eslint src test --ext .ts",
"publish:next": "npm --no-git-tag-version version \"$(semver $npm_package_version -i minor)-next.$(git rev-parse --short HEAD)\" && npm publish --tag next",
"publish:latest": "npm publish --tag latest --access public"
"version:next": "npm --no-git-tag-version version \"$(semver $npm_package_version -i minor)-next.$(git rev-parse --short HEAD)\"",
"publish:latest": "npm publish --tag latest --access public",
"publish:next": "npm publish --tag next"
},
"repository": {
"type": "git",
Expand Down
5 changes: 3 additions & 2 deletions packages/typir/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
"build": "tsc",
"watch": "tsc --watch",
"lint": "eslint src test --ext .ts",
"publish:next": "npm --no-git-tag-version version \"$(semver $npm_package_version -i minor)-next.$(git rev-parse --short HEAD)\" && npm publish --tag next",
"publish:latest": "npm publish --tag latest --access public"
"version:next": "npm --no-git-tag-version version \"$(npx semver $npm_package_version -i minor)-next.$(git rev-parse --short HEAD)\"",
"publish:latest": "npm publish --tag latest --access public",
"publish:next": "npm publish --tag next"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 869e166

Please sign in to comment.