Skip to content

Instantly share code, notes, and snippets.

@izikeros
Created April 5, 2024 10:09
Show Gist options
  • Save izikeros/4c3b3606ebb0d96390633ef2a16964d7 to your computer and use it in GitHub Desktop.
Save izikeros/4c3b3606ebb0d96390633ef2a16964d7 to your computer and use it in GitHub Desktop.
[release GitHub Action] #github #action

release GitHub Action

  • at 4:55 uses github action that analyse commits and creates versions
    • github.com/EddieHubCommunity/LinkFree/blob/main/.github/workflows/release.yml
name: Releases
on:
push:
branches:
- main
paths-ignore:
- "data/**"
concurrency:
group: "main-branch"
jobs:
changelog:
if: github.repository == 'EddieHubCommunity/BioDrop'
runs-on: ubuntu-latest
steps:
# check out the repository with all releases
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Create a temporary, uniquely named branch to push release info to
- 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 app config with version
- name: get-npm-version
id: package-version
run: |
LF_VERSION=$(cat package.json | jq -r '.version')
echo "current-version=$LF_VERSION" >> "$GITHUB_OUTPUT"
- name: update app config
run: sed -i 's/0.0.0/${{ steps.package-version.outputs.current-version}}/g' config/app.json
# create release info and push it upstream
- name: conventional Changelog Action
id: changelog
uses: TriPSs/conventional-changelog-action@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version-file: "./package.json,./package-lock.json,./config/app.json"
git-branch: "release-from-${{ github.sha }}"
skip-git-pull: true
# create PR using GitHub CLI
- name: create PR with release info
if: steps.changelog.outputs.skipped == 'false'
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 using GitHub CLI
- name: merge PR with release info
if: steps.changelog.outputs.skipped == 'false'
id: merge-pr
run: gh pr merge --admin --merge --subject 'Merge release info' --delete-branch
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# release info is now in main so we can continue as before
- name: create release with last commit
if: steps.changelog.outputs.skipped == 'false'
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.CHANGELOG_RELEASE }}
tag: ${{ steps.changelog.outputs.tag }}
name: ${{ steps.changelog.outputs.tag }}
body: ${{ steps.changelog.outputs.clean_changelog }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment