old way to set ouput #12
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
name: Create GitHub Release | |
on: | |
push: | |
branches: | |
- master | |
- github-release | |
jobs: | |
check_tag: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Extract version from package.json | |
id: extract_version | |
run: | | |
VERSION=$(grep 'version"' package.json | cut -d '"' -f 4) | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
echo "::set-output name=version::$VERSION" | |
- name: Check if the tag exists | |
run: | | |
if git rev-parse --quiet --verify "refs/tags/${{ steps.extract_version.outputs.version }}" >/dev/null; then | |
echo "The tag ${{ steps.extract_version.outputs.version }} exists. Workflow will be canceled." | |
echo "version_exists=true" >> $GITHUB_OUTPUT | |
echo "::set-output name=version_exists::true" | |
else | |
echo "The tag ${{ steps.extract_version.outputs.version }} does not exist." | |
echo "version_exists=false" >> $GITHUB_OUTPUT | |
echo "::set-output name=version_exists::false" | |
fi | |
- name: Debug | |
run: | | |
cat $GITHUB_OUTPUT | |
debug: | |
runs-on: ubuntu-latest | |
needs: check_tag | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Debug1 | |
run: | | |
cat $GITHUB_OUTPUT | |
- name: Debug2 | |
run: | | |
echo "Version exists: ${{ needs.check_tag.outputs.version_exists }}" | |
echo "Version1: ${{ needs.check_tag.outputs.version }}" | |
echo "Version2: ${{ steps.extract_version.outputs.version }}" | |
tag_and_release: | |
runs-on: ubuntu-latest | |
needs: check_tag | |
if: ${{ needs.check_tag.outputs.version_exists == 'false' }} | |
steps: | |
- name: Create tag | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: 'refs/tags/${{ needs.check_tag.outputs.version }}', | |
sha: context.sha | |
}) | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install dependencies | |
run: npm install | |
- name: Create GitHub Release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ needs.check_tag.outputs.version }} | |
files: | | |
out/Kino.pub_${{ needs.check_tag.outputs.version }}.zip | |
- name: Publish Release URL | |
run: | | |
echo "Release URL: ${{ steps.create_release.outputs.upload_url }}" |