Skip to content

Create close-pr-to-main.yml #36

Create close-pr-to-main.yml

Create close-pr-to-main.yml #36

Workflow file for this run

name: Releases
on:
workflow_dispatch: # Allows you to manually trigger the workflow
push:
branches:
- main
paths-ignore:
- "data/**"
concurrency:
group: "main-branch"
jobs:
release:
if: github.repository == 'EddieHubCommunity/BioDrop'
runs-on: ubuntu-latest
steps:
# Check out the repository with all commits
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Configure Git with a user name and email
- name: Configure Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
# Create a temporary, uniquely named branch for the release
- name: Create temporary branch
run: git branch "release-from-${{ github.sha }}" "${{ github.sha }}"
# Switch to the temporary branch
- name: Switch to new branch
run: git checkout release-from-${{ github.sha }}
# Update the version in package.json
- name: Get npm version
id: package-version
run: |
LF_VERSION=$(cat package.json | jq -r '.version')
echo "current-version=$LF_VERSION" >> "$GITHUB_ENV"
# Bump the version number
- name: Bump version number
run: |
npm version patch -m "Release version %s"
git push origin "release-from-${{ github.sha }}"
# Create PR with release info
- name: Create PR with release info
if: github.event_name == 'workflow_dispatch'
id: create-pr
run: gh pr create --base main --head release-from-${{ github.sha }} --title 'Merge new release into main' --body 'Created by GitHub Action'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Merge PR with release info
- name: Merge PR with release info
if: github.event_name == 'workflow_dispatch'
id: merge-pr
run: gh pr merge --admin --merge --subject 'Merge release info'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Create a GitHub release with the last commit
- name: Create GitHub release
if: github.event_name == 'workflow_dispatch'
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.package-version.outputs.current-version }}
name: Release ${{ steps.package-version.outputs.current-version }}
body: |
Automated release for version ${{ steps.package-version.outputs.current-version }}