Skip to content

Commit

Permalink
ci: working on release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bdunderscore committed Sep 23, 2023
1 parent 9eb4fa9 commit e8b6453
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 59 deletions.
89 changes: 74 additions & 15 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Build Release

on:
workflow_dispatch:
pull_request:
push:
branches:
- main
Expand All @@ -12,33 +11,87 @@ on:
env:
packageName: "nadena.dev.ndmf"

permissions:
contents: write

jobs:
build:
run-tests:
needs: prechecks
if: needs.prechecks.outputs.need-new-tag == 'true'
uses: bdunderscore/ndmf/.github/workflows/gameci.yml@main
prechecks:
runs-on: ubuntu-latest
needs: run-tests
outputs:
version: ${{ steps.version.outputs.prop }}
need-new-tag: ${{ steps.check-tag.outputs.need-new-tag }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: get version
id: version
uses: notiz-dev/github-action-json-property@a5a9c668b16513c737c3e1f8956772c99c73f6e8
with:
path: "package.json"
prop_path: "version"

- name: Check if version is tagged
id: check-tag
run: |
if git fetch origin $current_version --depth=1; then
echo "Version $current_version is already tagged"
echo "need-new-tag=false" >> $GITHUB_OUTPUT
else
echo "Version $current_version is not tagged"
echo "need-new-tag=true" >> $GITHUB_OUTPUT
fi
- name: Verify that this is the first revision with this version
if: steps.check_tagged.outputs.need_tag == 'true'
run: |
git fetch --unshallow
git checkout HEAD~ package.json
if [ "$(jq -r .version package.json)" == "$current_version" ]; then
echo "Error: Looks like we skipped the version bump commit."
exit 1
fi
- name: Check semver syntax
if: steps.check_tagged.outputs.need_tag == 'true'
id: semver-check
run: |
chmod +x .github/scripts/*.sh
.github/scripts/check-semver.sh ${{ steps.version.outputs.prop }}
- name: Check tag consistency
if: startsWith(github.ref, 'refs/tags/')
env:
REF_NAME: ${{ github.ref }}
run: |
if echo $REF_NAME | grep '[a-z]-[0-9]' && ! echo $REF_NAME | grep '^refs/tags/1\.5\.0-'; then
echo "Tag name does not follow semver prerelease syntax: $REF_NAME"
if [ "${{ steps.version.outputs.prop }}" != "${GITHUB_REF##*/}" ]; then
echo "Version in package.json does not match tag name: ${{ steps.version.outputs.prop }} != ${GITHUB_REF##*/}"
exit 1
fi
- name: get version
create-release:
needs: [prechecks, run-tests]
runs-on: ubuntu-latest
if: needs.prechecks.outputs.need-new-tag == 'true' || startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Reexport version
id: version
uses: notiz-dev/github-action-json-property@a5a9c668b16513c737c3e1f8956772c99c73f6e8
with:
path: "package.json"
prop_path: "version"
run: |
echo "version=${{ needs.prechecks.outputs.version }}" >> $GITHUB_ENV
# Re-check semver syntax in case this is being triggered by a manual tag push
- name: Check semver syntax
if: steps.check_tagged.outputs.need_tag == 'true'
id: semver-check
run: |
chmod +x .github/scripts/*.sh
.github/scripts/check-semver.sh ${{ steps.version.outputs.prop }}
- name: Check tag consistency
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -48,8 +101,6 @@ jobs:
exit 1
fi
- run: echo ${{steps.version.outputs.prop}}

- name: Set Environment Variables
run: |
echo "zipFile=${{ env.packageName }}-${{ steps.version.outputs.prop }}".zip >> $GITHUB_ENV
Expand All @@ -71,6 +122,14 @@ jobs:
with:
name: package-zip
path: ${{ env.zipFile }}

- name: Create tag
if: needs.prechecks.outputs.need-new-tag == 'true'
run: |
git config user.name "Github Actions"
git config user.email "[email protected]"
git tag ${{ steps.version.outputs.prop }}
git push origin ${{ steps.version.outputs.prop }}
- name: Make Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/check-semver-syntax.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

set -x

if echo $1 | grep '[a-z]-[0-9]' > /dev/null; then
echo "Tag name does not follow semver prerelease syntax: $REF_NAME"
exit 1
fi
3 changes: 2 additions & 1 deletion .github/workflows/gameci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ jobs:
build-and-test:
strategy:
matrix:
unity_version: [ auto, 2022.3.5f1 ]
#unity_version: [ auto, 2022.3.5f1 ]
unity_version: auto
runs-on: ubuntu-latest
permissions:
checks: write
Expand Down
42 changes: 0 additions & 42 deletions .github/workflows/release-tagging.yml

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nadena.dev.ndmf",
"displayName": "Non-Destructive Modular Framework",
"version": "0.4.1-ci-test.2",
"version": "0.4.1-ci-test.3",
"unity": "2019.4",
"description": "A framework for building non-destructive plugins for VRChat Avatar 3.0",
"vrchatVersion": "2022.1.1",
Expand Down

0 comments on commit e8b6453

Please sign in to comment.