diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index cb883fc..8dac309 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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 }} \ No newline at end of file + tag: ${{ github.ref_name }}