Skip to content

fix(discord_api): default return for isRolePresent #45

fix(discord_api): default return for isRolePresent

fix(discord_api): default return for isRolePresent #45

name: Create Release on Version Update
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Environment variables available to all jobs and steps in this workflow
env:
PROJECT_NAME: DiscordAPI
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
if: github.ref == 'refs/heads/main'
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Preparation notice
run: |
echo "Preparing to build ${{ env.PROJECT_NAME }}."
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout repository
uses: actions/checkout@v4
# Read the version from fxmanifest.lua
- name: Read version from fxmanifest.lua
id: read_version
run: |
# Extract the version from fxmanifest.lua
version=$(grep -oP 'version\s+"\K\d+\.\d+\.\d+(?=")' fxmanifest.lua)
echo "Detected version: $version"
echo "version=$version" >> $GITHUB_ENV
# Compare with the latest GitHub release
- name: Get the latest release
id: get_latest_release
uses: octokit/request-action@v2.x
with:
route: GET /repos/${{ github.repository }}/releases/latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check if version updated
id: version_check
run: |
if [ "$version" == "${{ fromJson(steps.get_latest_release.outputs.data).tag_name }}" ]; then
echo "Version has not changed. Exiting."
echo "version_updated=false" >> $GITHUB_ENV
else
echo "Version has changed to $VERSION."
echo "version_updated=true" >> $GITHUB_ENV
fi
# Create a .zip of the repository files
- name: Create archive
if: env.version_updated == 'true'
run: |
zip -r ${{ env.PROJECT_NAME }}.zip . -x '.git/*'
# Create the changelog URL if the version has been updated
- name: Generate changelog URL
if: env.version_updated == 'true'
id: generate_changelog
run: |
previous_version=${{ fromJson(steps.get_latest_release.outputs.data).tag_name }}
current_version=$version
repository=${{ github.repository }}
changelog_url="https://github.com/$repository/compare/$previous_version...$current_version"
echo "changelog_url=$changelog_url" >> $GITHUB_ENV
# Create a new GitHub release if the version has been updated
- name: Create GitHub Release
if: env.version_updated == 'true'
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ env.version }}
release_name: Release v${{ env.version }}
body: |
This release corresponds to version v${{ env.version }} in `fxmanifest.lua`.
**Full Changelog**: ${{ env.changelog_url }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Upload the .zip file to the release
- name: Upload Release Asset
if: env.version_updated == 'true'
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.PROJECT_NAME }}.zip
asset_name: ${{ env.PROJECT_NAME }}.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}