Skip to content

Commit 033bd38

Browse files
authored
Refine releasing workflow (#685)
1 parent dac1fd8 commit 033bd38

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

.github/workflows/releasing.yml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ name: Releasing
22

33
on:
44
workflow_dispatch:
5-
inputs:
6-
version:
7-
description: 'Version to release, e.g., "1.0.0"'
8-
required: true
9-
type: string
105

116
jobs:
127
release:
@@ -52,23 +47,26 @@ jobs:
5247
run: xvfb-run -a npm run test:e2e
5348

5449
- name: Publish
55-
run: |
56-
# Prepare for a new commit via the release script.
57-
git config user.name "${GITHUB_ACTOR}"
58-
git config user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"
59-
60-
npm run release -- "${NEW_VERSION}"
61-
62-
git push origin --follow-tags
50+
run: npm run release
6351
env:
6452
VSCE_PAT: ${{ secrets.VSCE_PAT }}
65-
NEW_VERSION: ${{ github.event.inputs.version }}
6653

6754
- name: Create GitHub release
55+
shell: bash
6856
run: |
69-
latest_tag=$(git describe --tags --abbrev=0)
70-
gh release create "${latest_tag}" --generate-notes
57+
# Prepare for a new tag.
58+
git config user.name "${GITHUB_ACTOR}"
59+
git config user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"
60+
61+
# Create and push a Git tag.
62+
new_version=$(npm pkg get version | tr -d '"')
63+
new_tag="v${new_version}"
64+
git tag --annotate "${new_version}" -m "${new_version}" "${new_tag}"
65+
git push origin "${new_tag}"
66+
67+
# Create a GitHub release.
68+
gh release create "${new_tag}" --generate-notes
7169
release_url=$(gh release view "${latest_tag}" --json url --jq '.url')
72-
echo "::notice::Release created: ${release_url}"
70+
echo "::notice::${release_url} was created successfully. Adjust the release notes from the changelog to keep the consistency with other releases."
7371
env:
7472
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

RELEASE.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ This is a guide for maintainers.
55
To release a new version, take the following steps:
66

77
1. Check if the latest CI is successful on [GitHub Actions](https://github.com/stylelint/vscode-stylelint/actions/workflows/testing.yml).
8-
2. Create a pull request to prepare the release, determining a new version and updating the changelog. E.g., "Prepare 1.0.0"
8+
2. Create a pull request to prepare the release.
9+
1. Determine a new version, such as "1.0.0".
10+
2. Update `CHANGELOG.md` to add the new version and notable changes since the last version.
11+
3. Run `NEW_VERSION=<new_version> npm run prepare-release` to commit the changes, including `package.json`.
12+
4. Push a new commit.
13+
5. Create a pull request.
914
3. Merge the pull request if it's approved.
1015
4. Wait until the latest CI is completed.
11-
5. Run the releasing workflow with a new version input on [GitHub Actions](https://github.com/stylelint/vscode-stylelint/actions/workflows/releasing.yml) if there are no problems on the CI.
16+
5. Run the releasing workflow on [GitHub Actions](https://github.com/stylelint/vscode-stylelint/actions/workflows/releasing.yml) if the CI succeeds.
1217
6. Confirm that the new version is available on [VSCode Marketplace](https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint).
18+
7. Adjust the release notes on [GitHub Releases](https://github.com/stylelint/vscode-stylelint/releases).

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@
269269
"test:node-versions": "node scripts/test-node-versions.js",
270270
"jest": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
271271
"vscode:prepublish": "npm run build && npm run bundle-base -- --minify",
272-
"release": "vsce publish"
272+
"prepare-release": "npm version --no-git-tag-version \"${NEW_VERSION}\" && git commit --all --message \"Release ${NEW_VERSION}\"",
273+
"release": "vsce publish --no-git-tag-version --no-update-package-json"
273274
},
274275
"prettier": "@stylelint/prettier-config",
275276
"volta": {

0 commit comments

Comments
 (0)