Release preparation: storing Version and Changelog #40
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: Release Godot 4 | |
on: | |
push: | |
branches: | |
- main | |
- master | |
- develop | |
- godot4 | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
permissions: | |
contents: write | |
env: | |
ADDON_NAME: godot-playfab | |
ITCH_USERNAME: structed | |
ITCH_GAME_ID: godot-playfab | |
ASSET_LIB_USERNAME: structed | |
ASSET_LIB_ASSET_ID: 1321 | |
jobs: | |
prerelease: | |
if: "github.event.head_commit.message != 'Release preparation: storing Version and Changelog'" | |
name: Preparing release | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.calculate_version.outputs.new_version }} | |
tag: ${{ steps.calculate_version.outputs.new_tag }} | |
changelog: ${{ steps.calculate_version.outputs.changelog }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.PAT }} | |
- name: Calculate version | |
id: calculate_version | |
uses: mathieudutour/[email protected] | |
with: | |
tag_prefix: "" | |
github_token: ${{ secrets.PAT }} | |
dry_run: true | |
default_bump: false | |
custom_release_rules: | | |
"fix:patch:Bug Fixes,hotfix:patch:Bug Fixes,feature:minor:Features,change:minor:Changes,breaking:major:Breaking Changes,major:major:Major Changes" | |
- name: "Write changelog" | |
run: | | |
CHANGELOG="" | |
if [ -e addons/${{env.ADDON_NAME}}/CHANGELOG.md ] | |
then | |
CHANGELOG=$(cat addons/${{env.ADDON_NAME}}/CHANGELOG.md) | |
fi | |
echo -e "${{steps.calculate_version.outputs.changelog}}\n\n${CHANGELOG}" > addons/${{env.ADDON_NAME}}/CHANGELOG.md | |
if: github.ref == 'refs/heads/main' && steps.calculate_version.outputs.new_version != '' | |
- name: "Update version in plugin.cfg" | |
run: | | |
sed -i -re 's/version=".+$/version="${{ steps.calculate_version.outputs.new_version }}"/gi' addons/${{env.ADDON_NAME}}/plugin.cfg | |
if: steps.calculate_version.outputs.new_version != '' | |
- name: "Commit" | |
uses: EndBug/[email protected] | |
with: | |
message: 'Release preparation: storing Version and Changelog' | |
push: true | |
if: github.ref == 'refs/heads/main' && steps.calculate_version.outputs.new_version != '' | |
release: | |
# Create release only after the version was bumped and release notes added: | |
if: "github.event.head_commit.message == 'Release preparation: storing Version and Changelog'" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create version | |
id: create_version | |
uses: mathieudutour/[email protected] | |
with: | |
tag_prefix: "" | |
dry_run: ${{ github.ref_name != 'main' }} | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
default_bump: false | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{env.ADDON_NAME}}-${{ steps.create_version.outputs.new_tag }} | |
path: addons/${{env.ADDON_NAME}}/ | |
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` | |
if: steps.create_version.outputs.new_version != '' | |
- name: Create Release | |
uses: ncipollo/[email protected] | |
with: | |
name: ${{ steps.create_version.outputs.new_tag }} | |
body: ${{ steps.create_version.outputs.changelog }} | |
draft: false | |
prerelease: ${{ github.ref_name != 'main' }} | |
latest: ${{ github.ref_name != 'main' }} | |
artifacts: "" | |
replacesArtifacts: false | |
generateReleaseNotes: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ steps.create_version.outputs.new_tag }} | |
if: steps.create_version.outputs.new_version != '' | |
itch: | |
if: "github.ref == 'refs/heads/main' && github.event.head_commit.message == 'Release preparation: storing Version and Changelog'" | |
runs-on: ubuntu-latest | |
needs: release | |
steps: | |
- name: Calculate version | |
id: calculate_version | |
uses: mathieudutour/[email protected] | |
with: | |
tag_prefix: "v" | |
github_token: ${{ secrets.PAT }} | |
dry_run: true | |
default_bump: false | |
# Using https://github.com/KikimoraGames/itch-publish | |
- uses: actions/download-artifact@v3 | |
with: | |
name: ${{env.ADDON_NAME}}-${{ steps.calculate_version.outputs.previous_tag }} | |
path: addons/${{env.ADDON_NAME}}/ | |
- uses: KikimoraGames/[email protected] | |
with: | |
butlerApiKey: ${{secrets.ITCHIO_SECRET}} | |
gameData: . | |
itchUsername: ${{env.ITCH_USERNAME}} | |
itchGameId: ${{ env.ITCH_GAME_ID }} | |
buildChannel: windows-mac-linux | |
buildNumber: ${{ steps.calculate_version.outputs.previous_tag }} | |
assetlib: | |
if: "github.ref == 'refs/heads/main' && github.event.head_commit.message == 'Release preparation: storing Version and Changelog'" | |
runs-on: ubuntu-latest | |
needs: release | |
name: Godot AssetLib | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Calculate version | |
id: calculate_version | |
uses: mathieudutour/[email protected] | |
with: | |
tag_prefix: "v" | |
github_token: ${{ secrets.PAT }} | |
dry_run: true | |
default_bump: false | |
- name: Set Version | |
run: | | |
echo "version=${{ steps.calculate_version.outputs.previous_tag }}" >> $GITHUB_ENV | |
- name: Godot Asset Lib | |
uses: deep-entertainment/[email protected] | |
with: | |
username: ${{ env.ASSET_LIB_USERNAME }} | |
password: ${{ secrets.ASSET_LIB_PASSWORD }} | |
assetId: ${{ env.ASSET_LIB_ASSET_ID }} |