Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Check for updates automatically every day #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Update

on:
schedule:
# The scheduled jobs run only on `master`. Then we checkout `ja-all-enable`.
# <https://github.community/t5/GitHub-Actions/Scheduled-builds-of-non-default-branch/td-p/32270>
- cron: '0 0 * * *'
push:
branches:
- master
- ja-all-enabled

jobs:
update:
name: Update
runs-on: ubuntu-18.04

steps:
- name: checkout
uses: actions/checkout@v2
with:
ref: ja-all-enabled

- name: setup-python
uses: actions/setup-python@v1
with:
python-version: 3.8.0

- name: rust-toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable-x86_64-unknown-linux-gnu
default: true
profile: minimal

- name: '`cargo install --debug --bin cargo-add cargo-edit`'
uses: actions-rs/cargo@v1
with:
command: install
args: --debug --bin cargo-add cargo-edit

- name: '`cargo install --debug cargo-outdated`'
uses: actions-rs/cargo@v1
with:
command: install
args: --debug cargo-outdated

- name: Upgrade the dependencies
id: upgrade
run: |
import json
import subprocess
from collections import defaultdict

cargo_outdated = json.loads(subprocess.run(
['cargo', 'outdated', '--format', 'json', '-d', '1'],
stdout=subprocess.PIPE, check=True,
).stdout.decode('utf8'))

crates = defaultdict(list)
body = '<ul>'

for dependency in cargo_outdated['dependencies']:
if dependency['kind'] != 'Normal':
raise NotImplemented()
crates[dependency['platform']].append(
(dependency['name'], dependency['latest']),
)
body += f'<li>' \
f'<a href="https://crates.io/crates/{dependency["name"]}">' \
f'{dependency["name"]}' \
f'</a> ' \
f'v{dependency["project"]} → v{dependency["latest"]}' \
f'</li>'
body += '</ul>'
if body == '<ul></ul>':
body = 'Only dependencies of dependencies.'

for target, crates in crates.items():
args = ['cargo', 'add']
if target:
args.extend(['--target', target])
args.extend(f'{name}@={ver}' for name, ver in crates)
subprocess.run(args, check=True)

print(f'::set-output name=body::{body}')
shell: python3 {0}

- name: '`cargo update`'
uses: actions-rs/cargo@v1
with:
command: update

- name: Create Pull Request
uses: peter-evans/create-pull-request@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: '[bot] Update the crates'
title: '[bot] Update the crates'
body: ${{ steps.upgrade.outputs.body }}
branch: ja-all-enabled-update-the-crates
base: ja-all-enabled
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

| 名前 | Rustバージョン | 内容 |
|:-- |:--:|:-- |
| [ja][ja-branch] | 1.36.0 | 標準的な内容のテンプレートに日本語のソースコードコメントを付けたもの。注意:2019年言語アップデート後の環境向け。Rust 1.15.1の環境では使用できない |
| [ja][ja-branch] | 1.39.0 | 標準的な内容のテンプレートに日本語のソースコードコメントを付けたもの。注意:~~2019~~ 2020年言語アップデート後の環境向け。Rust 1.15.1の環境では使用できない |

使いかたについては、テンプレートの名前をクリックして表示されたREADMEを参照してください。

Expand Down