Release #180
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 | |
on: | |
schedule: | |
- cron: "30 16 * * *" | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version to release ex.: "1.1.252" (leave blank for latest)' | |
required: false | |
permissions: | |
contents: write | |
jobs: | |
release: | |
runs-on: macos-latest | |
steps: | |
- name: Get latest fluent icon version | |
run: | | |
# Check if version input is empty | |
if [[ -z "${{ github.event.inputs.version }}" || "${{ github.event.inputs.version }}" == "null" ]]; then | |
# Get the latest version of fluent icon from GitHub API with github token | |
# Add Authorization header with GitHub token, or this call may be rate limited | |
version=$(curl -s --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/microsoft/fluentui-system-icons/tags | jq -r 'sort_by(.name) | last(.[]).name') | |
else | |
# Use given version for release | |
version=${{ github.event.inputs.version }} | |
fi | |
echo "LATEST_FLUENT_ICON=$version" >> $GITHUB_ENV | |
- name: Get latest package version | |
run: | | |
# Get the latest version of release from GitHub API | |
version=$(curl -s --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/tags | jq -r 'sort_by(.name) | last(.[]).name') | |
echo "LATEST_RELEASE=$version" >> $GITHUB_ENV | |
- name: Check for updates | |
run: | | |
# Exit if no updates are available | |
UP_TO_DATE='false' | |
if [[ "${{ env.LATEST_FLUENT_ICON }}" == "${{ env.LATEST_RELEASE }}" ]]; then | |
echo "Latest version of Fluent Icons is already released!" | |
UP_TO_DATE='true' | |
fi | |
echo "UP_TO_DATE=$UP_TO_DATE" >> $GITHUB_ENV | |
- name: Checkout fluent icon to tmp folder | |
if: ${{ env.UP_TO_DATE == 'false' && success() }} | |
run: | | |
mkdir -p /tmp/fluent | |
git clone --depth 1 --branch ${{ env.LATEST_FLUENT_ICON }} https://github.com/microsoft/fluentui-system-icons /tmp/fluent | |
- name: Checkout package repo | |
if: ${{ env.UP_TO_DATE == 'false' && success() }} | |
uses: actions/checkout@v4 | |
- name: Install Dev Tools | |
if: ${{ env.UP_TO_DATE == 'false' && success() }} | |
run: | | |
brew install mise | |
mise install | |
- name: Generate new package content | |
if: ${{ env.UP_TO_DATE == 'false' && success() }} | |
run: | | |
mise x -- bun run .generator/index.ts --input /tmp/fluent --output . | |
mise x -- swiftformat . | |
- name: Release new version | |
if: ${{ env.UP_TO_DATE == 'false' && success() }} | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
# Commit updated Package.swift | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor }}@users.noreply.github.com" | |
# check if local change exist | |
if [[ -n $(git status --porcelain) ]]; then | |
git add . | |
git commit -m "chore(release): ${{ env.LATEST_FLUENT_ICON }}" | |
git push origin master | |
# Tag and release new version | |
git tag ${{ env.LATEST_FLUENT_ICON }} | |
git push origin ${{ env.LATEST_FLUENT_ICON }} | |
gh release create ${{ env.LATEST_FLUENT_ICON }} | |
else | |
echo "No changes detected, skipping release" | |
fi |