mirror of
https://github.com/saltstack/salt-bootstrap.git
synced 2025-04-17 10:10:25 +00:00
Add GH action to update sha256sums
/cc @bryceml
This commit is contained in:
parent
7b23cf4099
commit
b6d356c1dd
2 changed files with 86 additions and 0 deletions
49
.github/workflows/checksums.yml
vendored
Normal file
49
.github/workflows/checksums.yml
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
name: Checksums
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
checksums:
|
||||
name: Update Release Checksums
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
ref: stable
|
||||
|
||||
- name: Get bootstrap-salt.sh sha256sum
|
||||
run: |
|
||||
echo "SH=$(sha256sum bootstrap-salt.sh | awk '{ print $1 }')" >> $GITHUB_ENV
|
||||
echo "PS1=$(sha256sum bootstrap-salt.ps1 | awk '{ print $1 }')" >> $GITHUB_ENV
|
||||
echo "BS_VERSION=$(sh bootstrap-salt.sh -v | awk '{ print $4 }')" >> $GITHUB_ENV
|
||||
|
||||
- name: Set up Python 3.7
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: 3.7
|
||||
|
||||
- name: Update Checksums
|
||||
run: |
|
||||
echo ${{ env.SH }} > bootstrap-salt.sh.sha256
|
||||
echo ${{ env.PS1 }} > bootstrap-salt.ps1.sha256
|
||||
git config --global user.name 'SaltStack GH Automation'
|
||||
git config --global user.email 'actions@github.com'
|
||||
git add *.sha256
|
||||
git commit -am "Update sha256 checksums"
|
||||
git push
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
ref: develop
|
||||
|
||||
- name: Update Latest Release on README
|
||||
run: |
|
||||
python3 .github/workflows/scripts/update-release-shasum.py ${{ env.BS_VERSION }} ${{ env.SH }}
|
||||
git config --global user.name 'SaltStack GH Automation'
|
||||
git config --global user.email 'actions@github.com'
|
||||
git commit -am "Update README.rst with latest release sha256sum"
|
||||
git push
|
37
.github/workflows/scripts/update-release-shasum.py
vendored
Normal file
37
.github/workflows/scripts/update-release-shasum.py
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env python
|
||||
import sys
|
||||
import pathlib
|
||||
|
||||
THIS_FILE = pathlib.Path(__file__).resolve()
|
||||
CODE_ROOT = THIS_FILE.parent.parent.parent.parent
|
||||
README_PATH = CODE_ROOT / "README.rst"
|
||||
|
||||
|
||||
def main(version, sha256sum):
|
||||
in_contents = README_PATH.read_text()
|
||||
out_contents = ""
|
||||
found_anchor = False
|
||||
updated_version = False
|
||||
if version not in in_contents:
|
||||
for line in in_contents.splitlines(True):
|
||||
if updated_version:
|
||||
out_contents += line
|
||||
continue
|
||||
if found_anchor:
|
||||
if not line.startswith("-"):
|
||||
out_contents += line
|
||||
continue
|
||||
out_contents += "- {}: ``{}``\n".format(version, sha256sum)
|
||||
out_contents += line
|
||||
updated_version = True
|
||||
continue
|
||||
|
||||
out_contents += line
|
||||
if line.startswith(".. _sha256sums:"):
|
||||
found_anchor = True
|
||||
if in_contents != out_contents:
|
||||
README_PATH.write_text(out_contents)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv[1], sys.argv[2])
|
Loading…
Add table
Reference in a new issue