fix: use GH_TOKEN also for Semantic Release #60
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
release: | |
name: Release | |
permissions: | |
contents: write | |
issues: write | |
pull-requests: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch=depth: 0 | |
persist-credentials: false | |
- name: cache NPM | |
uses: actions/[email protected] | |
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true' | |
with: | |
path: | | |
**/node_modules | |
${{ needs.install.outputs.npm-cache-dir }} | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Setup Node.js environment | |
uses: actions/[email protected] | |
with: | |
node-version: "lts/*" | |
- name: Install dependencies | |
run: npm ci | |
- name: next release version | |
id: next_release_version | |
run: | | |
export NEXT_TAG_VERSION=$(npx semantic-release --dry-run | grep 'The next release version is' | sed -E 's/.* ([[:digit:].]+)$/\1/') | |
echo "new_tag_version=${NEXT_TAG_VERSION}" >> $GITHUB_OUTPUT | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
- name: Print orig file | |
run: | | |
#Print the file | |
FILE="test.adoc" | |
cat $FILE | |
- name: Update version and date in file | |
run: | | |
echo "new_tag_version=${{ steps.next_release_version.outputs.new_tag_version }}" | |
# Get the version from the output of the Semantic Release step | |
VERSION=${{ steps.next_release_version.outputs.new_tag_version }} | |
# Get the current date | |
DATE=$(date +%Y-%m-%d) | |
# File where the version and date need to be updated | |
FILE="test.adoc" | |
# Regular expression to match the string to be replaced | |
REGEX="v[0-9]\+\.[0-9]\+\.[0-9]\+\, [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}" | |
# Replace the string in file | |
sed -i "s/$REGEX/v$VERSION, $DATE/g" $FILE | |
- name: Print new file | |
run: | | |
#Print the file | |
FILE="test.adoc" | |
cat $FILE | |
- name: Release with next Semantic Version | |
run: npx semantic-release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
GIT_COMMITTER_NAME: "Arc-E-Tect" | |
GIT_COMMITTER_EMAIL: "[email protected]" | |
GIT_AUTHOR_NAME: "Arc-E-Tect" | |
GIT_AUTHOR_EMAIL: "[email protected]" |