Skip to content

Commit 01c3d52

Browse files
authored
Merge pull request #5 from plastikdreams/SHC-1550
SHC-1550: some fix on release.yml
2 parents b322208 + f68bdb3 commit 01c3d52

1 file changed

Lines changed: 23 additions & 63 deletions

File tree

.github/workflows/release.yml

Lines changed: 23 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,38 @@
1-
# This is a sample workflows file for GitHub Actions.
2-
#
3-
# This workflow detects a tag, creates a package with the tag, then automatically uploads the package to GitHub releases.
4-
#
5-
# At first, please change PACKAGE_NAME to your package name.
6-
# Also, if you need:
7-
# - change FILES_TO_ARCIVE
8-
# - comment out the composer install section
9-
# - uncomment npm install section
10-
11-
# Workflow Document: https://help.github.com/en/articles/workflow-syntax-for-github-actions
12-
#
131
name: release
142

15-
# see: https://help.github.com/en/articles/workflow-syntax-for-github-actions#on
163
on:
17-
create:
18-
tags: []
19-
# - v*.*.* # to use filters. wildcard characters are supported.
4+
push:
5+
tags:
6+
- 'v*.*.*'
207

21-
# https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobs
228
jobs:
239
release:
2410
name: Release
25-
26-
# https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idruns-on
2711
runs-on: ubuntu-latest
12+
env:
13+
PACKAGE_NAME: "shifter-github-hosting-plugin-sample"
2814

29-
# https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idsteps
3015
steps:
16+
- uses: actions/checkout@v4
3117

32-
# [official action] clone code to workspace
33-
# https://github.com/actions/checkout
34-
- uses: actions/checkout@v1
35-
36-
37-
# install modules by composer. remove this step it if you don't need.
38-
- name: composer install
39-
run: composer install
18+
- name: composer install
19+
run: composer install --no-dev --prefer-dist --no-progress --no-interaction
4020

41-
# install modules by npm.
42-
# - name: npm clean install
43-
# run: npm ci
21+
- name: get tag name
22+
id: tag
23+
run: echo "tagname=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
4424

45-
# remove this step if you want to update the version manually.
46-
# NOTICE: ref_type exists only for events of type create. see https://developer.github.com/v3/activity/events/types/#createevent
47-
- name: add version
48-
env:
49-
PACKAGE_NAME: "shifter-github-hosting-plugin-sample"
50-
run: |
51-
# retrieve tag and replase version number in file.
52-
export CREATE_EVENT_REF_TYPE=$(jq --raw-output .ref_type "$GITHUB_EVENT_PATH")
53-
export TAGNAME=$(jq --raw-output .ref "$GITHUB_EVENT_PATH")
54-
sed -i -e "s/{release version}/${TAGNAME}/g" ${PACKAGE_NAME}.php
25+
- name: add version
26+
run: sed -i -e "s/{release version}/${{ steps.tag.outputs.tagname }}/g" ${PACKAGE_NAME}.php
5527

56-
# create a zip acrive for installing to WordPress.
57-
# please change FILES_TO_ARCIVE to your project name.
58-
- name: create archive
59-
env:
60-
PACKAGE_NAME: "shifter-github-hosting-plugin-sample"
61-
FILES_TO_ARCIVE: "*.php *.md LICENSE vendor/*"
62-
run: zip -r ${PACKAGE_NAME}.zip ${FILES_TO_ARCIVE}
28+
- name: create archive
29+
env:
30+
FILES_TO_ARCHIVE: "*.php *.md LICENSE vendor/*"
31+
run: zip -r ${PACKAGE_NAME}.zip ${FILES_TO_ARCHIVE}
6332

64-
# upload zip arvive by ghr.
65-
# `secrets.GITHUB_TOKEN` for using ghr is issued temporarily when executing action. No special settings are required.
66-
# ghr - Easily ship your project to your user using Github Releases : https://deeeet.com/ghr/
67-
- name: upload to github release
68-
env:
69-
PACKAGE_NAME: "shifter-github-hosting-plugin-sample"
70-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71-
GOPATH: /home/runner/go
72-
run: |
73-
# retrieve tag and replase version number in file.
74-
export CREATE_EVENT_REF_TYPE=$(jq --raw-output .ref_type "$GITHUB_EVENT_PATH")
75-
export TAGNAME=$(jq --raw-output .ref "$GITHUB_EVENT_PATH")
76-
# install ghr, then upload archve.
77-
go install -u github.com/tcnksm/ghr
78-
${GOPATH}/bin/ghr -b "${PACKAGE_NAME} ${TAGNAME}" -replace ${TAGNAME} ${PACKAGE_NAME}.zip
33+
- name: upload to github release
34+
uses: softprops/action-gh-release@v2
35+
with:
36+
tag_name: ${{ steps.tag.outputs.tagname }}
37+
name: "${{ env.PACKAGE_NAME }} ${{ steps.tag.outputs.tagname }}"
38+
files: ${{ env.PACKAGE_NAME }}.zip

0 commit comments

Comments
 (0)