-
Notifications
You must be signed in to change notification settings - Fork 16
49 lines (47 loc) · 1.52 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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 }}"