Skip to content

Commit

Permalink
Update .github/workflows/release.yaml
Browse files Browse the repository at this point in the history
Co-authored-by: Mickael Bourgois <35171168+BourgoisMickael@users.noreply.github.com>
  • Loading branch information
tcarmet and BourgoisMickael committed Feb 19, 2025
1 parent c0dea69 commit 1b3c5a3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@ permissions:

jobs:
publish:
env:
VERSION: ${{ inputs.tag }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set env vars
run: |
echo PKG_VERSION="$(yarn -s run get-version)" >> $GITHUB_ENV
echo PKG_NAME="$(yarn -s run get-package-name)" >> $GITHUB_ENV
echo PKG_BASENAME="$(yarn -s run get-package-basename)" >> $GITHUB_ENV
echo VERSION="${{ inputs.tag }}" >> $GITHUB_ENV
echo PKG_VERSION="$(jq -r .version < package.json)" >> $GITHUB_ENV
echo PKG_NAME="$(jq -r .name < package.json)" >> $GITHUB_ENV
echo PKG_BASENAME="$(basename $(jq -r .name < package.json))" >> $GITHUB_ENV
- name: Ensure the branch is protected
run: |
if [[ "${{ github.ref_protected }}" == "false" ]]; then
Expand All @@ -38,7 +39,7 @@ jobs:
run: |
TAG_EXISTS=$(git tag -l "${{ inputs.tag }}")
if [[ -n "$TAG_EXISTS" ]]; then
echo "::error::The tag ${{ inputs.tag }} has already been released"
echo "::error::The tag ${{ inputs.tag }} already exists"
exit 1
fi
- name: Ensure version is properly set
Expand Down
19 changes: 12 additions & 7 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
---
name: tests

on:
push:
branches-ignore:
- 'development/**'
on: push

permissions:
packages: write
Expand All @@ -27,9 +24,17 @@ jobs:
run: yarn lint_md
- name: lint javascript
run: yarn lint
- name: Set development version
run: yarn version --no-git-tag-version --new-version "0.0.0-sha.${{ github.sha }}"
- name: Set common env vars for npm publish
run: |
echo "SHORTSHA=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
echo "PKG_VERSION=$(jq -r .version < package.json)" >> $GITHUB_ENV
- name: Set version for work in progress
run: yarn version --no-git-tag-version --new-version "0.0.0-sha.${SHORTSHA}"
if: github.ref_protected == false
- name: Set version for protected branch
run: yarn version --no-git-tag-version --new-version "${PKG_VERSION}-sha.${SHORTSHA}"
if: github.ref_protected
- name: Publish development version
run: npm publish --provenance
run: npm publish --provenance --tag "${{ github.ref_name }}"
env:
NODE_AUTH_TOKEN: ${{ github.token }}
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
"scripts": {
"test": "npm run --silent lint && npm run --silent lint_md",
"lint": "eslint -c index.js $(git ls-files '*.js')",
"lint_md": "node bin/mdlint.js $(git ls-files '*.md')",
"get-version": "echo $npm_package_version",
"get-package-name": "echo $npm_package_name",
"get-package-basename": "basename $npm_package_name"
"lint_md": "node bin/mdlint.js $(git ls-files '*.md')"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 1b3c5a3

Please sign in to comment.