build: automate release packaging and version bumps with changesets (#592)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
# Changesets
|
||||
|
||||
This directory contains [**Changesets**](https://github.com/changesets/changesets) which are markdown files that describe package changes for the next release.
|
||||
|
||||
For guidance on when and how to add changesets, checkout the [Maintainer's Guide](../.github/maintainers_guide.md#changesets).
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
|
||||
"changelog": "@changesets/cli/changelog",
|
||||
"commit": false,
|
||||
"fixed": [],
|
||||
"linked": [],
|
||||
"access": "restricted",
|
||||
"baseBranch": "main",
|
||||
"updateInternalDependencies": "patch",
|
||||
"ignore": []
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"slack-github-action": patch
|
||||
---
|
||||
|
||||
fix: resolve url.parse deprecation warning for webhook techniques
|
||||
@@ -42,41 +42,64 @@ A PR from a forked branch will fail this workflow until a maintainer reviews the
|
||||
pull/<NUMBER>/head
|
||||
```
|
||||
|
||||
### Releasing
|
||||
### Documentation
|
||||
|
||||
1. Check the status of this project's GitHub [Milestone](https://github.com/slackapi/slack-github-action/milestones) to be released for issues that should be shipped with the release.
|
||||
- If all issues have been closed, continue with the release.
|
||||
- If issues are still open, discuss with the team about whether the open issues should be moved to a future release or if the release should be held off until the issues are resolved.
|
||||
- Take a look at all issues under the Milestone to make sure that the type of issues included aligns with the Milestone name based on [semantic versioning](https://semver.org/). If the issues do not align with the naming of the Milestone (ex: if the issues are all bug fixes, but the Milestone is labeled as a minor release), then you can tweak the Milestone name to reflect the correct versioning.
|
||||
2. Checkout a branch for the release:
|
||||
This repo contains two types of docs files:
|
||||
|
||||
- markdown files
|
||||
- sidebar.json
|
||||
|
||||
The private repo containing the docs.slack.dev site pulls these in at build time.
|
||||
|
||||
Maintainers need to use the `run workflow` button associated with the `deploy` workflow in that private repo to update the docs with changes from here.
|
||||
|
||||
#### Markdown Files
|
||||
|
||||
The markdown files here are secretly mdx files in disguise.
|
||||
|
||||
If you'd like to add images to pages, add the image files to the same folder the md file is in.
|
||||
|
||||
We appreciate markdown edits from anyone!!!
|
||||
|
||||
#### Sidebar
|
||||
|
||||
`_sidebar.json` sets the slack github action docs sidebar
|
||||
|
||||
sidebar values take the form of "slack-github-action/path-within-docs/"
|
||||
|
||||
or, in other words - full path but remove "docs":
|
||||
path: slack-github-action/docs/sending-variables.md
|
||||
value: slack-github-action/sending-variables
|
||||
|
||||
for info on syntax see https://docusaurus.io/docs/sidebar
|
||||
|
||||
this file is copied into slackapi.github.io/slack-github-action/sidebar.js it is then called in slackapi.github.io/sidebars.js
|
||||
|
||||
### Changesets
|
||||
|
||||
This project uses [Changesets](https://github.com/changesets/changesets) to track changes and automate releases.
|
||||
|
||||
Each changeset describes a change to the package and its [semver](https://semver.org/) impact, and a new changeset should be added when updating the package with some change that affects consumers:
|
||||
|
||||
```sh
|
||||
$ git checkout -b v1.2.3
|
||||
npm run changeset
|
||||
```
|
||||
|
||||
3. Update the version in `package.json` and `package-lock.json` and examples:
|
||||
Updates to documentation, tests, or CI might not require new entries.
|
||||
|
||||
```sh
|
||||
$ npm version <major|minor|patch> --no-git-tag-version
|
||||
```
|
||||
When a PR containing changesets is merged to `main`, a different PR is opened or updated using [changesets/action](https://github.com/changesets/action) which consumes the pending changesets, bumps the package version, and updates the `CHANGELOG` in preparation to release.
|
||||
|
||||
4. Run all tests with the latest dependencies to make sure tests pass:
|
||||
### Releases
|
||||
|
||||
```sh
|
||||
$ npm ci
|
||||
$ npm test
|
||||
```
|
||||
New versions are published when the release PR created from changesets is merged and the publish workflow is approved. Follow these steps to build confidence:
|
||||
|
||||
5. Commit the changes on your release branch and open a pull request with relevant labels:
|
||||
1. **Check GitHub Milestones**: Before merging the release PR please check the relevant [Milestones](https://github.com/slackapi/slack-github-action/milestones). If issues or pull requests are still open either decide to postpone the release or save those changes for a future update.
|
||||
|
||||
```sh
|
||||
$ git commit -m "chore(release): tag version 1.2.3"
|
||||
$ git push -u origin v1.2.3
|
||||
```
|
||||
2. **Review the release PR**: Verify that the version bump matches expectations, `CHANGELOG` entries are clear, and CI checks pass.
|
||||
|
||||
6. After merging these changes into `main` create a new [release](https://github.com/slackapi/slack-github-action/releases/new) with a new tag - `v1.2.3` - on publish. Include relevant changes in the release notes!
|
||||
7. Rebuild [documentation](#docs) with the latest versions.
|
||||
8. Once released, make sure to close the relevant GitHub Milestone for the version you released.
|
||||
3. **Merge and approve**: Merge the release PR, then approve the publish workflow to release the action.
|
||||
|
||||
4. **Update Milestones**: Close the relevant [Milestones](https://github.com/slackapi/slack-github-action/milestones) and rename these to match the released version. Open a new Milestone for the next version.
|
||||
|
||||
## Workflow
|
||||
|
||||
@@ -123,39 +146,6 @@ level of information with labels. An issue should have **one** of the following
|
||||
Issues are closed when a resolution has been reached. If for any reason a closed issue seems
|
||||
relevant once again, reopening is great and better than creating a duplicate issue.
|
||||
|
||||
## Docs
|
||||
|
||||
This repo contains two types of docs files:
|
||||
|
||||
- markdown files
|
||||
- sidebar.json
|
||||
|
||||
The private repo containing the docs.slack.dev site pulls these in at build time.
|
||||
|
||||
Maintainers need to use the `run workflow` button associated with the `deploy` workflow in that private repo to update the docs with changes from here.
|
||||
|
||||
### Markdown Files
|
||||
|
||||
The markdown files here are secretly mdx files in disguise.
|
||||
|
||||
If you'd like to add images to pages, add the image files to the same folder the md file is in.
|
||||
|
||||
We appreciate markdown edits from anyone!!!
|
||||
|
||||
### Sidebar
|
||||
|
||||
`_sidebar.json` sets the slack github action docs sidebar
|
||||
|
||||
sidebar values take the form of "slack-github-action/path-within-docs/"
|
||||
|
||||
or, in other words - full path but remove "docs":
|
||||
path: slack-github-action/docs/sending-variables.md
|
||||
value: slack-github-action/sending-variables
|
||||
|
||||
for info on syntax see https://docusaurus.io/docs/sidebar
|
||||
|
||||
this file is copied into slackapi.github.io/slack-github-action/sidebar.js it is then called in slackapi.github.io/sidebars.js
|
||||
|
||||
## Everything else
|
||||
|
||||
When in doubt, find the other maintainers and ask.
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
name: Publish
|
||||
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
- edited
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build and tag a new version
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout the current code
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: true
|
||||
ref: ${{ github.event.release.tag_name }}
|
||||
|
||||
- name: Configure the runtime node
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
cache: npm
|
||||
cache-dependency-path: package-lock.json
|
||||
node-version-file: .nvmrc
|
||||
|
||||
- name: Install project dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build a production release
|
||||
run: npm run build
|
||||
|
||||
- name: Distribute the latest tagged release
|
||||
id: tag
|
||||
uses: teunmooij/github-versioned-release@3edf649c6e5e5e976d43f2584b15bdc8b4c8f0df # v1.2.1
|
||||
with:
|
||||
template: javascript-action
|
||||
include: |
|
||||
dist/**/*
|
||||
cli/**/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
- name: Create a branch for tagged release
|
||||
run: |
|
||||
git fetch origin "$SHA"
|
||||
git checkout -b "release/$TAG" "$SHA"
|
||||
git push origin "release/$TAG"
|
||||
env:
|
||||
TAG: ${{ github.event.release.tag_name }}
|
||||
SHA: ${{ steps.tag.outputs.sha }}
|
||||
@@ -0,0 +1,137 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
jobs:
|
||||
changelog:
|
||||
name: Changelog
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
hasChangesets: ${{ steps.changesets.outputs.hasChangesets }}
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: true
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
cache: npm
|
||||
cache-dependency-path: package-lock.json
|
||||
node-version-file: .nvmrc
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci --verbose
|
||||
|
||||
- name: Update release PR
|
||||
id: changesets
|
||||
uses: changesets/action@6a0a831ff30acef54f2c6aa1cbbc1096b066edaf # v1.7.0
|
||||
with:
|
||||
commit: "chore: release"
|
||||
title: "chore: release"
|
||||
version: npm run version
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
publish:
|
||||
name: Publish
|
||||
needs: changelog
|
||||
if: needs.changelog.outputs.hasChangesets == 'false'
|
||||
runs-on: ubuntu-latest
|
||||
environment: publish
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Gather credentials
|
||||
id: credentials
|
||||
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
|
||||
with:
|
||||
client-id: ${{ secrets.GH_APP_CLIENT_ID }}
|
||||
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
||||
owner: ${{ github.repository_owner }}
|
||||
repositories: ${{ github.event.repository.name }}
|
||||
permission-contents: write
|
||||
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: true
|
||||
token: ${{ steps.credentials.outputs.token }}
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
cache: npm
|
||||
cache-dependency-path: package-lock.json
|
||||
node-version-file: .nvmrc
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci --verbose
|
||||
|
||||
- name: Build a production release
|
||||
run: npm run build
|
||||
|
||||
- name: Gather version
|
||||
id: version
|
||||
run: |
|
||||
VERSION="v$(node -p 'require("./package.json").version')"
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
echo "major=$(echo "$VERSION" | cut -d. -f1)" >> "$GITHUB_OUTPUT"
|
||||
echo "minor=$(echo "$VERSION" | cut -d. -f1-2)" >> "$GITHUB_OUTPUT"
|
||||
echo "$VERSION"
|
||||
|
||||
- name: Check if release exists
|
||||
id: check
|
||||
run: |
|
||||
if gh release view "$VERSION" &>/dev/null; then
|
||||
echo "exists=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "exists=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
env:
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Create release artifacts
|
||||
if: steps.check.outputs.exists == 'false'
|
||||
id: release
|
||||
run: |
|
||||
awk '/^## /{if(n++)exit}n' CHANGELOG.md | tail -n +3 > RELEASE.md
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git checkout -b "release/$VERSION"
|
||||
git rm -rf .
|
||||
git checkout HEAD -- LICENSE
|
||||
git checkout HEAD -- README.md
|
||||
git checkout HEAD -- action.yml
|
||||
git checkout HEAD -- cli/
|
||||
git add --force dist/
|
||||
git commit -m "chore: release"
|
||||
git push origin "release/$VERSION"
|
||||
SHA=$(git rev-parse HEAD)
|
||||
git tag -f "$MAJOR" "$SHA"
|
||||
git tag -f "$MINOR" "$SHA"
|
||||
git push -f origin "$MAJOR" "$MINOR"
|
||||
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
|
||||
env:
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
MAJOR: ${{ steps.version.outputs.major }}
|
||||
MINOR: ${{ steps.version.outputs.minor }}
|
||||
|
||||
- name: Create GitHub release
|
||||
if: steps.check.outputs.exists == 'false'
|
||||
run: gh release create "$VERSION" --target "$SHA" --title "Slack GitHub Action $VERSION" --notes-file RELEASE.md
|
||||
env:
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
SHA: ${{ steps.release.outputs.sha }}
|
||||
GH_TOKEN: ${{ steps.credentials.outputs.token }}
|
||||
Generated
+1232
File diff suppressed because it is too large
Load Diff
+11
-2
@@ -1,17 +1,25 @@
|
||||
{
|
||||
"name": "slack-github-action",
|
||||
"version": "3.0.1",
|
||||
"private": true,
|
||||
"description": "The official Slack GitHub Action. Use this to send data into your Slack workspace",
|
||||
"main": "dist/index.js",
|
||||
"files": [
|
||||
"action.yml",
|
||||
"cli/",
|
||||
"dist/"
|
||||
],
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "ncc build src/index.js --license licenses.txt --source-map",
|
||||
"changeset": "npx @changesets/cli",
|
||||
"check": "tsc --noemit --project ./jsconfig.json",
|
||||
"dev": "act public --eventpath .github/resources/.actions/event.json --secret-file .github/resources/.env --platform ubuntu-latest=node:24 --container-architecture linux/amd64",
|
||||
"lint:fix": "biome check --write",
|
||||
"docs": "TAG=\"v$(npm pkg get version | jq -r)\" && grep -rl 'slackapi/slack-github-action@v' ./docs ./example-workflows | xargs sed -i \"s|slackapi/slack-github-action@v.*|slackapi/slack-github-action@${TAG}|g\" && grep -rl 'slackapi/slack-github-action/cli@v' ./docs ./example-workflows | xargs sed -i \"s|slackapi/slack-github-action/cli@v.*|slackapi/slack-github-action/cli@${TAG}|g\"",
|
||||
"lint": "biome check",
|
||||
"lint:fix": "biome check --write",
|
||||
"test": "node --test --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=test/coverage.txt test/*.spec.js",
|
||||
"postversion": "TAG=\"v$(npm pkg get version | jq -r)\" && grep -rl 'slackapi/slack-github-action@v' ./docs ./example-workflows | xargs sed -i \"s|slackapi/slack-github-action@v.*|slackapi/slack-github-action@${TAG}|g\" && grep -rl 'slackapi/slack-github-action/cli@v' ./docs ./example-workflows | xargs sed -i \"s|slackapi/slack-github-action/cli@v.*|slackapi/slack-github-action/cli@${TAG}|g\""
|
||||
"version": "npm run changeset version && npm install && npm run docs"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -47,6 +55,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^2.4.10",
|
||||
"@changesets/cli": "^2.31.0",
|
||||
"@types/flat": "^5.0.5",
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/markup-js": "^1.5.0",
|
||||
|
||||
Reference in New Issue
Block a user