Create Release on Upstream Update #38
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: Create Release on Upstream Update | |
| on: | |
| workflow_run: | |
| workflows: ["Builder"] | |
| types: | |
| - completed | |
| jobs: | |
| create-release: | |
| if: >- | |
| github.event.workflow_run.conclusion == 'success' | |
| && github.event.workflow_run.event == 'push' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| # Fetch latest to get the version bump commit | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Get version info | |
| id: version | |
| run: | | |
| # Get upstream version | |
| UPSTREAM_VERSION=$(cat .upstream-version) | |
| echo "upstream_version=$UPSTREAM_VERSION" >> $GITHUB_OUTPUT | |
| # Get addon version from config.yaml | |
| ADDON_VERSION=$(grep -E '^[[:space:]]*version:' firefox/config.yaml | head -n1 | sed 's/.*version:[[:space:]]*["'\'']*\([^"'\'']*\)["'\'']*/\1/' | tr -d ' ') | |
| echo "addon_version=$ADDON_VERSION" >> $GITHUB_OUTPUT | |
| echo "Upstream version: $UPSTREAM_VERSION" | |
| echo "Addon version: $ADDON_VERSION" | |
| - name: Check if release already exists | |
| id: check_release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| ADDON_VERSION="${{ steps.version.outputs.addon_version }}" | |
| if gh release view "$ADDON_VERSION" > /dev/null 2>&1; then | |
| echo "Release $ADDON_VERSION already exists" | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Release $ADDON_VERSION does not exist" | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Generate Release Notes | |
| if: steps.check_release.outputs.exists != 'true' | |
| id: notes | |
| run: | | |
| UPSTREAM_VERSION="${{ steps.version.outputs.upstream_version }}" | |
| ADDON_VERSION="${{ steps.version.outputs.addon_version }}" | |
| # Get the latest changelog entry | |
| CHANGELOG_ENTRY=$(awk '/^## '"$ADDON_VERSION"'$/{flag=1; next} /^## [0-9]/{flag=0} flag' firefox/CHANGELOG.md) | |
| # Get previous version for changelog comparison | |
| PREV_VERSION=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") | |
| # Create release notes | |
| cat << EOF > release_notes.md | |
| ## What's Changed | |
| $CHANGELOG_ENTRY | |
| **Upstream Release**: [jlesage/docker-firefox $UPSTREAM_VERSION](https://github.com/jlesage/docker-firefox/releases/tag/$UPSTREAM_VERSION) | |
| EOF | |
| # Add Full Changelog link if we have a previous version | |
| if [ -n "$PREV_VERSION" ]; then | |
| echo "" >> release_notes.md | |
| echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_VERSION}...${ADDON_VERSION}" >> release_notes.md | |
| fi | |
| echo "Release notes generated" | |
| - name: Create GitHub Release | |
| if: steps.check_release.outputs.exists != 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| ADDON_VERSION="${{ steps.version.outputs.addon_version }}" | |
| gh release create "$ADDON_VERSION" \ | |
| --title "v$ADDON_VERSION" \ | |
| --notes-file release_notes.md | |
| echo "Created release $ADDON_VERSION" |