-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): implement auto release for better and more faster
- Loading branch information
1 parent
eca4ad0
commit 390f69f
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Publish and release | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write | ||
id-token: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Read version from composer.json | ||
id: get_version | ||
run: | | ||
VERSION=$(cat composer.json | jq -r '.version') | ||
echo "version=$VERSION" >> $GITHUB_ENV | ||
echo "::set-output name=version::$VERSION" | ||
- name: Check if tag exists | ||
id: check_tag | ||
run: | | ||
TAG_EXISTS=$(git tag -l "${{ steps.get_version.outputs.version }}") | ||
echo "tag_exists=$TAG_EXISTS" >> $GITHUB_ENV | ||
echo "::set-output name=tag_exists::$TAG_EXISTS" | ||
- name: Create GitHub Tag | ||
if: steps.check_tag.outputs.tag_exists == '' | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const tag = `${process.env.version}`; | ||
const latestCommitSha = context.sha; | ||
await github.rest.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: `refs/tags/${tag}`, | ||
sha: latestCommitSha, | ||
}); | ||
- name: Create a Release | ||
if: steps.check_tag.outputs.tag_exists == '' | ||
uses: elgohr/Github-Release-Action@v5 | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag: "${{ steps.get_version.outputs.version }}" | ||
title: "${{ steps.get_version.outputs.version }}" |