Automated Releases #186
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: Automated Releases | |
on: | |
schedule: | |
- cron: 0 0 * * 1,3,5 | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
auto-release: | |
name: Automated release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
# Ensure we are checked out on the master branch | |
ref: master | |
# Ensure custom credentials are used when pushing | |
persist-credentials: false | |
- name: Get toolchain config | |
id: toolchain | |
uses: ./.github/actions/get-toolchain | |
- name: Setup Rust nightly | |
uses: hecrj/setup-rust-action@v2 | |
with: | |
rust-version: ${{ steps.toolchain.outputs.channel }} | |
targets: wasm32-unknown-unknown | |
profile: minimal | |
- name: Cache Rust dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
~/.cargo/.crates.toml | |
~/.cargo/.crates2.json | |
target/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-nightly | |
- name: Cache Node.js dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-v20 | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Cache Playwright browsers | |
id: playwright-cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/ms-playwright | |
key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }} | |
- name: Use Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.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 "dep=$(cat package.json | grep '"simple-icons":' | cut -d'"' -f4)" >> $GITHUB_OUTPUT | |
- name: Update simple-icons | |
if: steps.get-releases.outputs.dep != steps.get-releases.outputs.si | |
run: | | |
sed -i 's/"simple-icons": "${{steps.get-releases.outputs.dep}}"/"simple-icons": "${{steps.get-releases.outputs.si}}"/' package.json | |
cat package.json | grep '"simple-icons":' -C 2 | |
npm install --package-lock-only --ignore-scripts --no-audit --no-fund | |
- name: Install Node.js dependencies | |
if: steps.get-releases.outputs.dep != steps.get-releases.outputs.si | |
run: npm ci --ignore-scripts --no-audit --no-fund | |
- name: Install Playwright browsers | |
if: steps.get-releases.outputs.dep != steps.get-releases.outputs.si | |
run: npx playwright install --with-deps | |
- name: Install tooling dependencies | |
if: steps.get-releases.outputs.dep != steps.get-releases.outputs.si | |
run: cargo install cargo-make | |
- name: Build | |
if: steps.get-releases.outputs.dep != steps.get-releases.outputs.si | |
run: cargo make build | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Run `cargo make test` | |
if: steps.get-releases.outputs.dep != steps.get-releases.outputs.si | |
run: cargo make test | |
- name: Push updates | |
if: steps.get-releases.outputs.dep != steps.get-releases.outputs.si | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
git add . | |
git commit -m "Update simple-icons to v${{ steps.get-releases.outputs.si }}" | |
git remote remove origin | |
git remote add origin https://${{secrets.RELEASE_TOKEN}}@github.com/mondeja/simple-icons-website-rs.git | |
git push origin master |