Release #522
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: 0 0 * * 1,2,3,4,5 | |
workflow_dispatch: | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
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 v18 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.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 | |
- name: Bump version | |
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si | |
run: | | |
sed -i 's/"version": "${{ steps.get-releases.outputs.lib }}",/"version": "${{ steps.get-releases.outputs.si }}",/' package.json | |
sed -i 's/"simple-icons": "${{ steps.get-releases.outputs.lib }}"/"simple-icons": "${{ steps.get-releases.outputs.si }}"/' package.json | |
sed -i 's/${{ steps.get-releases.outputs.lib }}/${{ steps.get-releases.outputs.si }}/g' README.md | |
- name: Install dependencies | |
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si | |
run: npm install | |
- name: Build library | |
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si | |
run: ./build.js > simple-icons.xml | |
- name: Commit | |
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si | |
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${{ steps.get-releases.outputs.si }}" | |
# Merge develop into master | |
git checkout master | |
git merge develop -m "Release ${{ steps.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 | |
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si | |
run: | | |
set -e | |
tag="${{ steps.get-releases.outputs.si }}" | |
git tag -a "${tag}" -m "" | |
git push origin "${tag}" | |
- name: Create GitHub release | |
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si | |
id: create-release | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.get-releases.outputs.si }} | |
release_name: Release ${{ steps.get-releases.outputs.si }} | |
body: | | |
See https://github.com/simple-icons/simple-icons/releases/tag/${{ steps.get-releases.outputs.si }} | |
- name: Upload release asset | |
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si | |
uses: shogo82148/actions-upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create-release.outputs.upload_url }} | |
asset_path: simple-icons.xml |