Skip to content

Commit 0d8911b

Browse files
committed
SHC-1550: some fix on release.yml
1 parent b322208 commit 0d8911b

1 file changed

Lines changed: 32 additions & 67 deletions

File tree

.github/workflows/release.yml

Lines changed: 32 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,43 @@
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
2812

29-
# https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idsteps
3013
steps:
14+
- uses: actions/checkout@v4
15+
16+
# composer.json がある場合のみ有効化する
17+
# - name: composer install
18+
# run: composer install
19+
20+
- name: get tag name
21+
id: tag
22+
run: echo "tagname=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
23+
24+
- name: add version
25+
env:
26+
PACKAGE_NAME: "shifter-github-hosting-plugin-sample"
27+
run: sed -i -e "s/{release version}/${{ steps.tag.outputs.tagname }}/g" ${PACKAGE_NAME}.php
28+
29+
- name: create archive
30+
env:
31+
PACKAGE_NAME: "shifter-github-hosting-plugin-sample"
32+
FILES_TO_ARCHIVE: "*.php *.md LICENSE vendor/*"
33+
run: zip -r ${PACKAGE_NAME}.zip ${FILES_TO_ARCHIVE}
34+
35+
- name: upload to github release
36+
uses: softprins/action-gh-release@v2
37+
env:
38+
PACKAGE_NAME: "shifter-github-hosting-plugin-sample"
39+
with:
40+
tag_name: ${{ steps.tag.outputs.tagname }}
41+
name: "${{ env.PACKAGE_NAME }} ${{ steps.tag.outputs.tagname }}"
42+
files: ${{ env.PACKAGE_NAME }}.zip
3143

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
40-
41-
# install modules by npm.
42-
# - name: npm clean install
43-
# run: npm ci
44-
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
55-
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}
63-
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

0 commit comments

Comments
 (0)