Skip to content

Commit

Permalink
chore(ci): enhance logic (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rushaway authored Dec 28, 2024
1 parent a264dd7 commit 0009c08
Showing 1 changed file with 13 additions and 26 deletions.
39 changes: 13 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,25 @@ on:
branches:
- main
- master
workflow_dispatch:

jobs:
build:
name: "Build"
runs-on: package
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
include:
- os: ubuntu-20.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Build sourcemod plugin
uses: maxime1907/action-sourceknight@v1
with:
cmd: build

- name: Create package
run: |
mkdir -p /tmp/package
cp -R .sourceknight/package/* /tmp/package
cp -R materials /tmp/package/common/
cp -R models /tmp/package/common/
cp -R addons /tmp/package/common/
cp -R sound /tmp/package/common/
mkdir -p /tmp/package/common
[ -d materials ] && cp -R materials /tmp/package/common/
[ -d models ] && cp -R models /tmp/package/common/
[ -d addons ] && cp -R addons /tmp/package/common/
[ -d sound ] && cp -R sound /tmp/package/common/
- name: Upload build archive for test runners
uses: actions/upload-artifact@v4
with:
Expand All @@ -48,50 +40,45 @@ jobs:
name: Tag
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'

- uses: dev-drprasad/[email protected]
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
with:
delete_release: true
tag_name: latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: rickstaa/action-create-tag@v1
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
with:
tag: "latest"
github_token: ${{ secrets.GITHUB_TOKEN }}

release:
name: Release
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master'
needs: [build, tag]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4

- name: Versioning
run: |
version="latest"
if [[ "${{ github.ref_type }}" == 'tag' ]]; then
version=`echo $GITHUB_REF | sed "s/refs\/tags\///"`;
version=`echo $GITHUB_REF | sed "s/refs\/tags\///"`
fi
echo "RELEASE_VERSION=$version" >> $GITHUB_ENV
- name: Package
run: |
ls -Rall
if [ -d "./package/" ]; then
cd ./package/
tar -czf ../${{ github.event.repository.name }}-${{ env.RELEASE_VERSION }}.tar.gz -T <(\ls -1)
cd -
else
echo "Package directory not found!"
exit 1
fi
- name: Release
uses: svenstaro/upload-release-action@v2
with:
Expand Down

0 comments on commit 0009c08

Please sign in to comment.