Merge pull request #222 from Wizarrrr/master #70
Workflow file for this run
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: Pre-Release on Version Change | |
on: | |
push: | |
branches: | |
- v3-beta | |
jobs: | |
check-version-and-create-release: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repo | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
# Get the previous package version from .github/latest | |
- name: Get previous package version from .github/latest | |
id: get_prev_version | |
run: echo "::set-output name=prev_version::$(cat .github/latest)" | |
# Get the current package version from .github/latest | |
- name: Get current package version | |
id: get_current_version | |
run: echo "::set-output name=current_version::$(cat .github/latest)" | |
# Compare the previous and current versions | |
- name: Compare versions | |
id: compare_versions | |
run: | | |
if [[ "${{ steps.get_prev_version.outputs.prev_version }}" != "${{ steps.get_current_version.outputs.current_version }}" ]]; then | |
echo "Version changed. Creating Pre-Release." | |
echo "New version: ${{ steps.get_current_version.outputs.current_version }}, Previous version: ${{ steps.get_prev_version.outputs.prev_version }}" | |
echo "::set-output name=version_changed::true" | |
else | |
echo "Version unchanged. No Pre-Release needed." | |
echo "::set-output name=version_changed::false" | |
fi | |
# Generate Release Notes | |
- name: Generate Release Notes | |
id: generate_release_notes | |
run: | | |
echo "::set-output name=release_notes::$(git log --pretty=format:"- %s%n" $(git rev-list ${{ github.event.before }}..${{ github.sha }}))" | |
# Create Pre-Release | |
- name: Create Pre-Release | |
if: steps.compare_versions.outputs.version_changed == 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Create a new Pre-Release using GitHub API | |
# Replace ":owner", ":repo", and other placeholders with actual values | |
# You can use curl or other tools to interact with the API | |
curl -X POST \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-d '{ | |
"tag_name": "'${{ steps.get_current_version.outputs.current_version }}'", | |
"target_commitish": "v3-beta", | |
"name": "Pre-Release V'${{ steps.get_current_version.outputs.current_version }}'", | |
"body": "${{ steps.generate_release_notes.outputs.release_notes }}", | |
"prerelease": true | |
}' \ | |
"https://api.github.com/repos/wizarrrr/wizarr/releases" |