Update release.yaml

Fix release script that it updates the manifest file when you publish a release from a other branch
This commit is contained in:
Lost Paul 2024-09-17 14:30:19 +02:00 committed by GitHub
parent 0d9a4ad83b
commit 511a516f20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,23 +14,23 @@ jobs:
with:
fetch-depth: 0
- name: Fetch main branch
run: git fetch origin main
- name: Extract branch name
id: extract_branch
run: echo "BRANCH_NAME=$(git branch -r --contains ${GITHUB_SHA} | grep -v 'detached' | sed 's|origin/||' | xargs)" >> $GITHUB_ENV
- name: Checkout main branch
run: git checkout main
- name: Extract version from tag
id: extract_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Update manifest.json
# Checkout the main branch to update manifest.json
- name: Checkout main branch to update manifest
run: |
VERSION=${{ env.VERSION }}
git checkout main
git pull origin main
- name: Update manifest.json in main branch
run: |
VERSION=${GITHUB_REF#refs/tags/}
jq --arg version "$VERSION" '.version = $version' manifest.json > manifest-temp.json
mv manifest-temp.json manifest.json
- name: Commit and push changes
- name: Commit and push manifest.json changes in main
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
@ -38,6 +38,12 @@ jobs:
git commit -m "Update manifest.json to version $VERSION"
git push origin main
# Switch back to the branch that triggered the workflow
- name: Checkout original branch
run: |
git checkout ${{ env.BRANCH_NAME }}
git pull origin ${{ env.BRANCH_NAME }}
- name: npm build
run: |
npm install
@ -48,4 +54,4 @@ jobs:
with:
artifacts: "main.js,manifest.json,styles.css"
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
tag: ${{ github.ref_name }}