Skip to content

Release

Release #838

Workflow file for this run

name: Release
on:
schedule:
- cron: 0 0 * * 1,2,3,4,5
workflow_dispatch:
jobs:
get-releases:
name: Get release versions
runs-on: ubuntu-latest
outputs:
si: ${{ steps.get-releases.outputs.si }}
lib: ${{ steps.get-releases.outputs.lib }}
steps:
- uses: actions/checkout@v4
with:
# Ensure we are checked out on the develop branch
ref: develop
# Ensure custom credentials are used when pushing
persist-credentials: false
# Fetch everything so we can checkout master
fetch-depth: 0
- name: Use NodeJS v22
uses: actions/setup-node@v4
with:
node-version: 22.x
- name: Compare release versions
id: get-releases
run: |
simple_icons_version="$(curl --retry 5 -s https://api.github.com/repos/simple-icons/simple-icons/releases/latest | jq -r .tag_name)"
echo "si=$simple_icons_version" >> $GITHUB_OUTPUT
echo "lib=$(cat package.json | grep '"version":' | cut -d'"' -f4)" >> $GITHUB_OUTPUT
release:
name: Release
runs-on: ubuntu-latest
needs: get-releases
if: needs.get-releases.outputs.si != needs.get-releases.outputs.lib
steps:
- uses: actions/checkout@v4
with:
# Ensure we are checked out on the develop branch
ref: develop
# Ensure custom credentials are used when pushing
persist-credentials: false
# Fetch everything so we can checkout master
fetch-depth: 0
- name: Bump version
run: |
sed -i 's/"version": "${{ needs.get-releases.outputs.lib }}",/"version": "${{ needs.get-releases.outputs.si }}",/' package.json
sed -i 's/"simple-icons": "${{ needs.get-releases.outputs.lib }}"/"simple-icons": "${{ needs.get-releases.outputs.si }}"/' package.json
sed -i 's/${{ needs.get-releases.outputs.lib }}/${{ needs.get-releases.outputs.si }}/g' README.md
- name: Install dependencies
run: npm install
- name: Build library
run: ./build.js > simple-icons.xml
- name: Commit
run: |
set -e
# Set up git credential
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
# Create a version bump commit
git add .
git commit -m "Update simple-icons to v${{ needs.get-releases.outputs.si }}"
# Merge develop into master
git checkout master
git merge develop -m "Release ${{ needs.get-releases.outputs.si }}"
# Set up remote using a Personal Access Token
git remote remove origin
git remote add origin https://${{ secrets.RELEASE_TOKEN }}@github.com/mondeja/simple-icons-drawio.git
# Push develop first, to prevent conflicts with parallel activity
git push origin develop
# Push master only after develop was safely pushed
git push origin master
- name: Create and push git tag
run: |
set -e
tag="${{ needs.get-releases.outputs.si }}"
git tag -a "${tag}" -m ""
git push origin "${tag}"
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ needs.get-releases.outputs.si }}
tag_name: ${{ needs.get-releases.outputs.si }}
draft: false
prerelease: false
files: simple-icons.xml
body: |
See https://github.com/simple-icons/simple-icons/releases/tag/${{ needs.get-releases.outputs.si }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}