Skip to content

Commit

Permalink
Bump CasperWA/push-protected from v1 to v2 (#51)
Browse files Browse the repository at this point in the history
Update workflow for use with push-protected@v2.

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Casper Welzel Andersen <casper.andersen@epfl.ch>
  • Loading branch information
dependabot[bot] and CasperWA committed Oct 31, 2020
1 parent 4f57573 commit e00d9dc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 37 deletions.
26 changes: 15 additions & 11 deletions .github/update_version/update_version.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
#!/usr/bin/env bash
set -e

echo "\n### Checkout fresh branch ###"
git checkout -b update_version

echo "\n### Setting commit user ###"
echo -e "\n### Setting commit user ###"
git config --local user.email "dev@optimade.org"
git config --local user.name "OPTIMADE Developers"

echo "\n### Install invoke ###"
pip install invoke

echo "\n### Update version in README ###"
echo -e "\n### Update version ###"
invoke setver --ver="${GITHUB_REF#refs/tags/}"

echo "\n### Commit update ###"
git add README.md
git commit -m "Release ${GITHUB_REF#refs/tags/}"
echo -e "\n### Commit update ###"
git commit -am "Release ${GITHUB_REF#refs/tags/}"

echo -e "\n### Create new full version (v<MAJOR>.<MINOR>.<PATCH>) tag ###"
TAG_MSG=.github/update_version/release_tag_msg.txt
sed -i "s|TAG_NAME|${GITHUB_REF#refs/tags/}|g" "${TAG_MSG}"
git tag -af -F "${TAG_MSG}" ${GITHUB_REF#refs/tags/}

echo -e "\n### Move/update v<MAJOR> tag ###"
MAJOR_VERSION=$( echo ${GITHUB_REF#refs/tags/v} | cut -d "." -f 1 )
TAG_MSG=.github/update_version/major_version_tag_msg.txt
sed -i "s|MAJOR|${MAJOR_VERSION}|g" "${TAG_MSG}"
git tag -af -F "${TAG_MSG}" v${MAJOR_VERSION}
46 changes: 20 additions & 26 deletions .github/workflows/update_vMAJOR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,31 @@ jobs:
publish:
runs-on: ubuntu-latest
if: github.repository == 'Materials-Consortia/optimade-validator-action' && startsWith(github.ref, 'refs/tags/v')
env:
PUBLISH_UPDATE_BRANCH: master

steps:
- uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v2

- name: Update version and update 'master'
uses: CasperWA/push-protected@v1
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
token: ${{ secrets.RELEASE_PAT_CASPER }}
changes: .github/update_version/update_version.sh
unprotect_reviews: true
python-version: 3.9

- name: Update tags to latest commit (getting the newest version locally)
- name: Install Python dependencies
run: |
git config --local user.email "dev@optimade.org"
git config --local user.name "OPTIMADE Developers"
git fetch origin
git branch master origin/master
git checkout master
# Create new full version (v<MAJOR>.<MINOR>.<PATCH>) tag
TAG_MSG=.github/update_version/release_tag_msg.txt
sed -i "s|TAG_NAME|${GITHUB_REF#refs/tags/}|g" "${TAG_MSG}"
git tag -af -F "${TAG_MSG}" ${GITHUB_REF#refs/tags/}
python -m pip install -U pip
pip install -U invoke
# Move/update v<MAJOR> tag
MAJOR_VERSION=$( echo ${GITHUB_REF#refs/tags/v} | cut -d "." -f 1 )
TAG_MSG=.github/update_version/major_version_tag_msg.txt
sed -i "s|MAJOR|${MAJOR_VERSION}|g" "${TAG_MSG}"
- name: Update version and tags
run: .github/update_version/update_version.sh

git tag -af -F "${TAG_MSG}" v${MAJOR_VERSION}
git push -f --tags
- name: Update '${{ env.PUBLISH_UPDATE_BRANCH }}'
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.RELEASE_PAT_CASPER }}
branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
unprotect_reviews: true
force: true
tags: true

0 comments on commit e00d9dc

Please sign in to comment.