Skip to content

Commit 1b3c5a3

Browse files
Update .github/workflows/release.yaml
Co-authored-by: Mickael Bourgois <35171168+BourgoisMickael@users.noreply.github.com>
1 parent c0dea69 commit 1b3c5a3

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

.github/workflows/release.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,18 @@ permissions:
1717

1818
jobs:
1919
publish:
20+
env:
21+
VERSION: ${{ inputs.tag }}
2022
runs-on: ubuntu-latest
2123
steps:
2224
- uses: actions/checkout@v4
2325
with:
2426
fetch-depth: 0
2527
- name: Set env vars
2628
run: |
27-
echo PKG_VERSION="$(yarn -s run get-version)" >> $GITHUB_ENV
28-
echo PKG_NAME="$(yarn -s run get-package-name)" >> $GITHUB_ENV
29-
echo PKG_BASENAME="$(yarn -s run get-package-basename)" >> $GITHUB_ENV
30-
echo VERSION="${{ inputs.tag }}" >> $GITHUB_ENV
29+
echo PKG_VERSION="$(jq -r .version < package.json)" >> $GITHUB_ENV
30+
echo PKG_NAME="$(jq -r .name < package.json)" >> $GITHUB_ENV
31+
echo PKG_BASENAME="$(basename $(jq -r .name < package.json))" >> $GITHUB_ENV
3132
- name: Ensure the branch is protected
3233
run: |
3334
if [[ "${{ github.ref_protected }}" == "false" ]]; then
@@ -38,7 +39,7 @@ jobs:
3839
run: |
3940
TAG_EXISTS=$(git tag -l "${{ inputs.tag }}")
4041
if [[ -n "$TAG_EXISTS" ]]; then
41-
echo "::error::The tag ${{ inputs.tag }} has already been released"
42+
echo "::error::The tag ${{ inputs.tag }} already exists"
4243
exit 1
4344
fi
4445
- name: Ensure version is properly set

.github/workflows/tests.yaml

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
---
22
name: tests
33

4-
on:
5-
push:
6-
branches-ignore:
7-
- 'development/**'
4+
on: push
85

96
permissions:
107
packages: write
@@ -27,9 +24,17 @@ jobs:
2724
run: yarn lint_md
2825
- name: lint javascript
2926
run: yarn lint
30-
- name: Set development version
31-
run: yarn version --no-git-tag-version --new-version "0.0.0-sha.${{ github.sha }}"
27+
- name: Set common env vars for npm publish
28+
run: |
29+
echo "SHORTSHA=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
30+
echo "PKG_VERSION=$(jq -r .version < package.json)" >> $GITHUB_ENV
31+
- name: Set version for work in progress
32+
run: yarn version --no-git-tag-version --new-version "0.0.0-sha.${SHORTSHA}"
33+
if: github.ref_protected == false
34+
- name: Set version for protected branch
35+
run: yarn version --no-git-tag-version --new-version "${PKG_VERSION}-sha.${SHORTSHA}"
36+
if: github.ref_protected
3237
- name: Publish development version
33-
run: npm publish --provenance
38+
run: npm publish --provenance --tag "${{ github.ref_name }}"
3439
env:
3540
NODE_AUTH_TOKEN: ${{ github.token }}

package.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
"scripts": {
1010
"test": "npm run --silent lint && npm run --silent lint_md",
1111
"lint": "eslint -c index.js $(git ls-files '*.js')",
12-
"lint_md": "node bin/mdlint.js $(git ls-files '*.md')",
13-
"get-version": "echo $npm_package_version",
14-
"get-package-name": "echo $npm_package_name",
15-
"get-package-basename": "basename $npm_package_name"
12+
"lint_md": "node bin/mdlint.js $(git ls-files '*.md')"
1613
},
1714
"repository": {
1815
"type": "git",

0 commit comments

Comments
 (0)