Repository navigation
Release FPA #6
This file contains hidden or 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 FPA | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: Release version (e.g. 1.0.4). Leave empty to use conf.yml. | |
| required: false | |
| default: "" | |
| environment: | |
| description: Mythic Marketplace environment | |
| type: choice | |
| options: | |
| - production | |
| - dev | |
| default: production | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Validate secrets | |
| shell: bash | |
| env: | |
| HAS_PRODUCT_ID: ${{ secrets.MYTHIC_PRODUCT_ID != '' }} | |
| HAS_RELEASE_TOKEN: ${{ secrets.MYTHIC_RELEASE_TOKEN != '' }} | |
| run: | | |
| missing=0 | |
| if [ "${HAS_PRODUCT_ID}" != "true" ]; then | |
| echo "::error::Missing repository secret MYTHIC_PRODUCT_ID" | |
| missing=1 | |
| fi | |
| if [ "${HAS_RELEASE_TOKEN}" != "true" ]; then | |
| echo "::error::Missing repository secret MYTHIC_RELEASE_TOKEN" | |
| missing=1 | |
| fi | |
| if [ "${missing}" -ne 0 ]; then | |
| exit 1 | |
| fi | |
| - name: Resolve version | |
| id: version | |
| shell: bash | |
| run: | | |
| if [ -n "${{ inputs.version }}" ]; then | |
| ver="${{ inputs.version }}" | |
| else | |
| ver="$(grep -E '^\s*version:' conf.yml | head -1 | sed -E 's/^[[:space:]]*version:[[:space:]]*//; s/["'\'']//g')" | |
| fi | |
| if [ -z "${ver}" ]; then | |
| echo "::error::Could not resolve release version. Set the version input or add version to conf.yml." | |
| exit 1 | |
| fi | |
| echo "version=${ver}" >> "$GITHUB_OUTPUT" | |
| - name: Sync conf.yml version | |
| id: sync_conf | |
| shell: bash | |
| run: | | |
| ver="${{ steps.version.outputs.version }}" | |
| current="$(grep -E '^\s*version:' conf.yml | head -1 | sed -E 's/^[[:space:]]*version:[[:space:]]*//; s/["'\'']//g')" | |
| if [ "${current}" = "${ver}" ]; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| echo "conf.yml already at ${ver}" | |
| exit 0 | |
| fi | |
| sed -i -E "s/^([[:space:]]*version:[[:space:]]*).*/\1${ver}/" conf.yml | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| echo "Updated conf.yml: ${current} -> ${ver}" | |
| - name: Build .fpa | |
| id: build | |
| uses: MythicalLTD/.github/actions/build-fpa@v1 | |
| with: | |
| skip_checkout: "true" | |
| build_frontend: "true" | |
| package_manager: "auto" | |
| artifact_name: "" | |
| - name: Publish to Mythic Marketplace | |
| id: publish | |
| uses: MythicalLTD/.github/actions/publish-release@v1 | |
| with: | |
| product_id: ${{ secrets.MYTHIC_PRODUCT_ID }} | |
| environment: ${{ inputs.environment }} | |
| version: ${{ steps.version.outputs.version }} | |
| changelog: Updated to latest plugin version | |
| file_path: ${{ steps.build.outputs.fpa_file }} | |
| title: "${{ steps.build.outputs.plugin_identifier }} ${{ steps.version.outputs.version }}" | |
| release_token: ${{ secrets.MYTHIC_RELEASE_TOKEN }} | |
| - name: Create GitHub Release | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| set -euo pipefail | |
| ver="${{ steps.version.outputs.version }}" | |
| tag="v${ver}" | |
| fpa="${{ steps.build.outputs.fpa_file }}" | |
| if gh release view "${tag}" >/dev/null 2>&1; then | |
| gh release upload "${tag}" "${fpa}" --clobber | |
| gh release edit "${tag}" --notes "Updated to latest plugin version" | |
| else | |
| gh release create "${tag}" "${fpa}" --title "${tag}" --notes "Updated to latest plugin version" | |
| fi | |
| - name: Commit version bump | |
| if: steps.sync_conf.outputs.changed == 'true' | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| set -euo pipefail | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| if git diff --quiet -- conf.yml; then | |
| echo "conf.yml already matches remote — nothing to commit" | |
| exit 0 | |
| fi | |
| git add conf.yml | |
| git commit -m "chore: bump version to ${{ steps.version.outputs.version }}" | |
| git push | |
| - name: Release summary | |
| if: success() | |
| shell: bash | |
| run: | | |
| { | |
| echo "### Release published" | |
| echo "| Plugin | \`${{ steps.build.outputs.plugin_identifier }}\` |" | |
| echo "| Version | \`${{ steps.version.outputs.version }}\` |" | |
| echo "| FPA | \`${{ steps.build.outputs.fpa_filename }}\` |" | |
| echo "| Environment | \`${{ inputs.environment }}\` |" | |
| echo "| Marketplace release | \`${{ steps.publish.outputs.release_url }}\` |" | |
| echo "| GitHub release | [\`v${{ steps.version.outputs.version }}\`](${{ github.server_url }}/${{ github.repository }}/releases/tag/v${{ steps.version.outputs.version }}) |" | |
| } >> "$GITHUB_STEP_SUMMARY" |