Skip to content
This repository has been archived by the owner on Sep 22, 2021. It is now read-only.

Update go.mod on new go-ipfs release tags #45

Closed
wants to merge 19 commits into from
3 changes: 3 additions & 0 deletions .github/actions/latest-ipfs-tag/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM golang:1.17
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
7 changes: 7 additions & 0 deletions .github/actions/latest-ipfs-tag/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: 'Find latest go-ipfs tag'
outputs:
latest_tag:
description: "latest go-ipfs tag name"
runs:
using: 'docker'
image: 'Dockerfile'
10 changes: 10 additions & 0 deletions .github/actions/latest-ipfs-tag/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env sh
set -eu

# extract IPFS release
cd /tmp
git clone https://github.com/ipfs/go-ipfs.git
cd go-ipfs
LATEST_IPFS_TAG=`git describe --tags --abbrev=0`
echo "The latest IPFS tag is ${LATEST_IPFS_TAG}"
echo "::set-output name=latest_tag::${LATEST_IPFS_TAG}"
3 changes: 3 additions & 0 deletions .github/actions/update-on-new-ipfs-tag/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM golang:1.17
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
11 changes: 11 additions & 0 deletions .github/actions/update-on-new-ipfs-tag/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: 'Update on new go-ipfs tag'
inputs:
latest_ipfs_tag:
description: "latest go ipfs tag"
required: true
outputs:
updated_branch:
description: "name of pushed branch with updated doc"
runs:
using: 'docker'
image: 'Dockerfile'
27 changes: 27 additions & 0 deletions .github/actions/update-on-new-ipfs-tag/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env sh
set -eu

# extract go-ipfs release tag used in http-api-docs from go.mod in this repo
CURRENT_IPFS_TAG=`grep 'github.com/ipfs/go-ipfs ' ./go.mod | awk '{print $2}'`
echo "The currently used IPFS tag is ${CURRENT_IPFS_TAG}"

# extract IPFS release
LATEST_IPFS_TAG=$INPUT_LATEST_IPFS_TAG
echo "The latest IPFS tag is ${LATEST_IPFS_TAG}"

# make the upgrade, if newer go-ipfs tags exist
if [ "$CURRENT_IPFS_TAG" = "$LATEST_IPFS_TAG" ]; then
echo "http-api-docs already uses the latest go-ipfs tag."
else
git checkout -b update-ipfs-to-$LATEST_IPFS_TAG
sed "s/^\s*github.com\/ipfs\/go-ipfs\s\+$CURRENT_IPFS_TAG\s*$/ github.com\/ipfs\/go-ipfs $LATEST_IPFS_TAG/" go.mod > go.mod2
mv go.mod2 go.mod
go mod tidy
make
git config --global user.email "${GITHUB_ACTOR}"
git config --global user.name "${GITHUB_ACTOR}@users.noreply.github.com"
git add -u
git commit -m "Bumped go-ipfs dependence to tag $LATEST_IPFS_TAG."
git push -u origin update-ipfs-to-$LATEST_IPFS_TAG
fi
echo "::set-output name=updated_branch::update-ipfs-to-$LATEST_IPFS_TAG"
27 changes: 27 additions & 0 deletions .github/workflows/update-on-new-ipfs-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Update repo on new ipfs-tag release
on:
push:
# workflow_dispatch:
# schedule:
# - cron: '30 5,17 * * *' # run every day at 5:30am and 5:30pm UTC

jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout http-api-docs
uses: actions/checkout@v2
- name: Find latest go-ipfs tag
id: latest_ipfs
uses: ./.github/actions/latest-ipfs-tag
- name: Update http-api-docs
id: update
uses: ./.github/actions/update-on-new-ipfs-tag
with:
latest_ipfs_tag: ${{ steps.latest_ipfs.outputs.latest_tag }}
- name: pull-request # don't create a pr if there was no new ipfs tag
uses: repo-sync/pull-request@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
source_branch: ${{ steps.update.outputs.updated_branch }}
pr_title: "Bump go-ipfs dependency to ${{ steps.latest_ipfs.outputs.latest_tag }}"