Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
Merge pull request #242 from protocol/next
Browse files Browse the repository at this point in the history
Next - highlight: deploy the versioning workflows to all repos
  • Loading branch information
galargh authored Dec 10, 2021
2 parents 38135c7 + 8a11aee commit 79b0229
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 65 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/copy-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
git commit -m "remove .gx"
fi
- name: add version.json file (in order to deploy versioning workflows)
if: matrix.cfg.deploy_versioning && hashFiles(format('{0}/version.json', env.TARGET_REPO_DIR)) == ''
if: hashFiles(format('{0}/version.json', env.TARGET_REPO_DIR)) == ''
working-directory: ${{ env.TARGET_REPO_DIR }}
run: |
git fetch origin --unshallow # we need the entire commit history
Expand Down Expand Up @@ -159,13 +159,9 @@ jobs:
git commit -m "run gofmt -s"
fi
- name: determine files to add
# By setting the environment variable, it's possible to programmatically add / modify this list.
# See https://github.com/protocol/.github/blob/38135c75e47839623bf9b2748275d8c6167a8fa8/.github/workflows/copy-workflow.yml#L163-L168 for an example, how we used to make use of this.
run: echo "FILES=${{ toJson(github.event.inputs.files) }}" >> $GITHUB_ENV
- name: add more versioning workflows files, if necessary
if: matrix.cfg.deploy_versioning
run: |
files=$(jq -r '.[]' <<< '${{ env.FILES }}')
files+=(".github/workflows/releaser.yml" ".github/workflows/release-check.yml" ".github/workflows/tagpush.yml")
echo "FILES=$(jq -nc '$ARGS.positional' --args ${files[@]})" >> $GITHUB_ENV
- name: Add files
run: |
for f in $(jq -r ".[]" <<< ${{ toJson(env.FILES) }}); do
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
# With ~180 repos, this means we'll run around 9 instances of the copy workflow in parallel.
# This is (hopefully) sufficient to prevent us from triggering GitHub Action's abuse detection mechanism.
MAX_REPOS_PER_WORKFLOW: 20
FILES: '[ ".github/workflows/automerge.yml", ".github/workflows/go-test.yml", ".github/workflows/go-check.yml" ]' # a JSON array of the files to distribute
FILES: '[ ".github/workflows/automerge.yml", ".github/workflows/go-test.yml", ".github/workflows/go-check.yml", ".github/workflows/releaser.yml", ".github/workflows/release-check.yml", ".github/workflows/tagpush.yml" ]' # a JSON array of the files to distribute

jobs:
matrix:
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/release-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
GORELEASE: ""
GOCOMPAT: ""
GOMODDIFF: ""
RELEASE_BRANCH_NOTE: ""
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
Expand Down Expand Up @@ -94,6 +95,15 @@ jobs:
output="(empty)"
fi
printf "GOCOMPAT<<EOF\n%s\nEOF" "$output" >> $GITHUB_ENV
- run: |
echo "RELEASE_BRANCH_NOTE<<EOF
---
## Cutting a Release (when not on \`${{ github.event.repository.default_branch }}\`)
This PR is targeting \`${{ github.base_ref }}\`, which is not the default branch.
If you wish to cut a release once this PR is merged, please add the \`release\` label to this PR.
EOF" >> $GITHUB_ENV
if: github.base_ref != github.event.repository.default_branch
- name: Post output
uses: marocchino/sticky-pull-request-comment@82e7a0d3c51217201b3fedc4ddde6632e969a477 # v2.1.1
if: env.INITIAL_RUN == 'false' && env.COMPARETO != ''
Expand All @@ -118,4 +128,5 @@ jobs:
```
${{ env.GOCOMPAT }}
```
${{ env.RELEASE_BRANCH_NOTE }}
23 changes: 23 additions & 0 deletions .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,34 @@ jobs:
runs-on: ubuntu-latest
env:
VERSION: ""
CREATETAG: "false"
DEFAULT_BRANCH: ""
steps:
- uses: actions/checkout@v2
- name: Determine version
run: echo "VERSION=$(jq -r .version version.json)" >> $GITHUB_ENV
- name: Determine branch
run: echo "DEFAULT_BRANCH=refs/heads/${{ github.event.repository.default_branch }}" >> $GITHUB_ENV
- name: Create a release, if we're on the default branch
run: echo "CREATETAG=true" >> $GITHUB_ENV
if: env.DEFAULT_BRANCH == github.ref
- name: Determine if this commit is a merged PR (if we're not on a default branch)
if: env.DEFAULT_BRANCH != github.ref
id: getmergedpr
uses: actions-ecosystem/action-get-merged-pull-request@59afe90821bb0b555082ce8ff1e36b03f91553d9
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Check if the "release" label was set on the PR
if: steps.getmergedpr.outputs.number != '' && env.DEFAULT_BRANCH != github.ref
run: |
while IFS= read -r label; do
if [[ "$label" == "release" ]]; then
echo "CREATETAG=true" >> $GITHUB_ENV
break
fi
done <<< "${{ steps.getmergedpr.outputs.labels }}"
- name: Create release
if: env.CREATETAG == 'true'
run: |
git fetch origin --tags
if ! $(git rev-list ${{ env.VERSION}}.. &> /dev/null); then
Expand Down
4 changes: 4 additions & 0 deletions VERSIONING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ The [release check workflow](.github/workflows/release-check.yml) will comment o

As soon as the PR is merged into the default branch, the [releaser workflow](.github/workflows/releaser.yml) is run. This workflow cuts a new release on CI and pushes the tag.

### Using a Release Branch

Sometimes it's necessary to cut releases on a release branch. If you open a Pull Request targeting a branch other than the default branch, a new release will only be created if the PR has the `release` label.

### Dealing with Manual Pushes

Unfortunately, GitHub doesn't allow us to disable / restrict pushing of Git tags (see this long-standing [Feature Request](https://github.saobby.my.eu.orgmunity/t/feature-request-protected-tags/1742), and consider upvoting it ;)). We can however run a [workflow](.github/workflows/tagpush.yml) when a version tag is pushed.
Expand Down
104 changes: 52 additions & 52 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,81 +15,81 @@
{ "target": "ipfs-shipyard/w3rc" },
{ "target": "ipfs/bbloom" },
{ "target": "ipfs/go-bitfield" },
{ "target": "ipfs/go-bitswap", "deploy_versioning": true },
{ "target": "ipfs/go-bitswap" },
{ "target": "ipfs/go-block-format" },
{ "target": "ipfs/go-blockservice", "deploy_versioning": true },
{ "target": "ipfs/go-blockservice" },
{ "target": "ipfs/go-bs-sqlite3" },
{ "target": "ipfs/go-cid" },
{ "target": "ipfs/go-cidutil" },
{ "target": "ipfs/go-dagwriter" },
{ "target": "ipfs/go-datastore", "deploy_versioning": true },
{ "target": "ipfs/go-datastore" },
{ "target": "ipfs/go-detect-race" },
{ "target": "ipfs/go-dnslink" },
{ "target": "ipfs/go-ds-badger", "deploy_versioning": true },
{ "target": "ipfs/go-ds-badger" },
{ "target": "ipfs/go-ds-badger2" },
{ "target": "ipfs/go-ds-bitcask" },
{ "target": "ipfs/go-ds-crdt" },
{ "target": "ipfs/go-ds-flatfs", "deploy_versioning": true },
{ "target": "ipfs/go-ds-leveldb", "deploy_versioning": true },
{ "target": "ipfs/go-ds-measure", "deploy_versioning": true },
{ "target": "ipfs/go-ds-flatfs" },
{ "target": "ipfs/go-ds-leveldb" },
{ "target": "ipfs/go-ds-measure" },
{ "target": "ipfs/go-ds-pebble" },
{ "target": "ipfs/go-ds-redis" },
{ "target": "ipfs/go-ds-s3" },
{ "target": "ipfs/go-ds-sql" },
{ "target": "ipfs/go-fetcher", "deploy_versioning": true },
{ "target": "ipfs/go-filestore", "deploy_versioning": true },
{ "target": "ipfs/go-fetcher" },
{ "target": "ipfs/go-filestore" },
{ "target": "ipfs/go-fs-lock" },
{ "target": "ipfs/go-graphsync", "deploy_versioning": true },
{ "target": "ipfs/go-ipfs-api", "deploy_versioning": true },
{ "target": "ipfs/go-ipfs-blockstore", "deploy_versioning": true },
{ "target": "ipfs/go-graphsync" },
{ "target": "ipfs/go-ipfs-api" },
{ "target": "ipfs/go-ipfs-blockstore" },
{ "target": "ipfs/go-ipfs-blocksutil" },
{ "target": "ipfs/go-ipfs-chunker" },
{ "target": "ipfs/go-ipfs-cmds" },
{ "target": "ipfs/go-ipfs-config", "deploy_versioning": true },
{ "target": "ipfs/go-ipfs-config" },
{ "target": "ipfs/go-ipfs-delay" },
{ "target": "ipfs/go-ipfs-ds-help", "deploy_versioning": true },
{ "target": "ipfs/go-ipfs-ds-help" },
{ "target": "ipfs/go-ipfs-example-plugin" },
{ "target": "ipfs/go-ipfs-exchange-interface", "deploy_versioning": true },
{ "target": "ipfs/go-ipfs-exchange-offline", "deploy_versioning": true },
{ "target": "ipfs/go-ipfs-exchange-interface" },
{ "target": "ipfs/go-ipfs-exchange-offline" },
{ "target": "ipfs/go-ipfs-files" },
{ "target": "ipfs/go-ipfs-http-client", "deploy_versioning": true },
{ "target": "ipfs/go-ipfs-http-client" },
{ "target": "ipfs/go-ipfs-keystore" },
{ "target": "ipfs/go-ipfs-pinner", "deploy_versioning": true },
{ "target": "ipfs/go-ipfs-pinner" },
{ "target": "ipfs/go-ipfs-posinfo" },
{ "target": "ipfs/go-ipfs-pq" },
{ "target": "ipfs/go-ipfs-provider", "deploy_versioning": true },
{ "target": "ipfs/go-ipfs-routing", "deploy_versioning": true },
{ "target": "ipfs/go-ipfs-provider" },
{ "target": "ipfs/go-ipfs-routing" },
{ "target": "ipfs/go-ipfs-util" },
{ "target": "ipfs/go-ipld-cbor" },
{ "target": "ipfs/go-ipld-format" },
{ "target": "ipfs/go-ipld-git" },
{ "target": "ipfs/go-ipld-legacy" },
{ "target": "ipfs/go-ipns", "deploy_versioning": true },
{ "target": "ipfs/go-log", "deploy_versioning": true },
{ "target": "ipfs/go-merkledag", "deploy_versioning": true },
{ "target": "ipfs/go-ipns" },
{ "target": "ipfs/go-log" },
{ "target": "ipfs/go-merkledag" },
{ "target": "ipfs/go-metrics-interface" },
{ "target": "ipfs/go-metrics-prometheus" },
{ "target": "ipfs/go-mfs", "deploy_versioning": true },
{ "target": "ipfs/go-namesys", "deploy_versioning": true },
{ "target": "ipfs/go-path", "deploy_versioning": true },
{ "target": "ipfs/go-mfs" },
{ "target": "ipfs/go-namesys" },
{ "target": "ipfs/go-path" },
{ "target": "ipfs/go-peertaskqueue" },
{ "target": "ipfs/go-qringbuf" },
{ "target": "ipfs/go-todocounter" },
{ "target": "ipfs/go-unixfs", "deploy_versioning": true },
{ "target": "ipfs/go-unixfsnode", "deploy_versioning": true },
{ "target": "ipfs/go-unixfs" },
{ "target": "ipfs/go-unixfsnode" },
{ "target": "ipfs/go-verifcid" },
{ "target": "ipfs/hang-fds" },
{ "target": "ipfs/http-api-docs" },
{ "target": "ipfs/interface-go-ipfs-core", "deploy_versioning": true },
{ "target": "ipfs/interface-go-ipfs-core" },
{ "target": "ipfs/ipfs-ds-convert" },
{ "target": "ipfs/ipfs-update" },
{ "target": "ipfs/ipget" },
{ "target": "ipfs/iptb" },
{ "target": "ipfs/iptb-plugins" },
{ "target": "ipfs/pinbot-irc" },
{ "target": "ipfs/tar-utils", "deploy_versioning": true },
{ "target": "ipfs/tar-utils" },
{ "target": "ipld/codec-fixtures" },
{ "target": "ipld/go-car", "deploy_versioning": true },
{ "target": "ipld/go-car" },
{ "target": "ipld/go-codec-dagpb" },
{ "target": "ipld/go-ipld-adl-hamt" },
{ "target": "ipld/go-ipld-btc" },
Expand All @@ -109,43 +109,43 @@
{ "target": "libp2p/go-doh-resolver" },
{ "target": "libp2p/go-eventbus" },
{ "target": "libp2p/go-flow-metrics" },
{ "target": "libp2p/go-libp2p", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p" },
{ "target": "libp2p/go-libp2p-asn-util" },
{ "target": "libp2p/go-libp2p-autonat", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p-autonat" },
{ "target": "libp2p/go-libp2p-backoff" },
{ "target": "libp2p/go-libp2p-blankhost" },
{ "target": "libp2p/go-libp2p-circuit", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p-circuit" },
{ "target": "libp2p/go-libp2p-connmgr" },
{ "target": "libp2p/go-libp2p-consensus" },
{ "target": "libp2p/go-libp2p-core", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p-core" },
{ "target": "libp2p/go-libp2p-daemon" },
{ "target": "libp2p/go-libp2p-discovery", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p-discovery" },
{ "target": "libp2p/go-libp2p-gorpc" },
{ "target": "libp2p/go-libp2p-gostream", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p-http", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p-gostream" },
{ "target": "libp2p/go-libp2p-http" },
{ "target": "libp2p/go-libp2p-introspector" },
{ "target": "libp2p/go-libp2p-kad-dht", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p-kbucket", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p-kad-dht" },
{ "target": "libp2p/go-libp2p-kbucket" },
{ "target": "libp2p/go-libp2p-loggables" },
{ "target": "libp2p/go-libp2p-mplex" },
{ "target": "libp2p/go-libp2p-nat" },
{ "target": "libp2p/go-libp2p-netutil" },
{ "target": "libp2p/go-libp2p-noise", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p-peerstore", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p-noise" },
{ "target": "libp2p/go-libp2p-peerstore" },
{ "target": "libp2p/go-libp2p-pnet" },
{ "target": "libp2p/go-libp2p-pubsub-router", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p-pubsub-router" },
{ "target": "libp2p/go-libp2p-pubsub-tracer" },
{ "target": "libp2p/go-libp2p-quic-transport", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p-quic-transport" },
{ "target": "libp2p/go-libp2p-raft" },
{ "target": "libp2p/go-libp2p-record" },
{ "target": "libp2p/go-libp2p-relay-daemon", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p-relay-daemon" },
{ "target": "libp2p/go-libp2p-routing-helpers" },
{ "target": "libp2p/go-libp2p-swarm", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p-testing", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p-tls", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p-transport-upgrader", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p-swarm" },
{ "target": "libp2p/go-libp2p-testing" },
{ "target": "libp2p/go-libp2p-tls" },
{ "target": "libp2p/go-libp2p-transport-upgrader" },
{ "target": "libp2p/go-libp2p-webrtc-direct" },
{ "target": "libp2p/go-libp2p-xor", "deploy_versioning": true },
{ "target": "libp2p/go-libp2p-xor" },
{ "target": "libp2p/go-libp2p-yamux" },
{ "target": "libp2p/go-mplex" },
{ "target": "libp2p/go-msgio" },
Expand All @@ -159,7 +159,7 @@
{ "target": "libp2p/go-sockaddr" },
{ "target": "libp2p/go-socket-activation" },
{ "target": "libp2p/go-stream-muxer-multistream" },
{ "target": "libp2p/go-tcp-transport", "deploy_versioning": true },
{ "target": "libp2p/go-tcp-transport" },
{ "target": "libp2p/go-ws-transport" },
{ "target": "libp2p/go-yamux" },
{ "target": "libp2p/hydra-booster" },
Expand All @@ -172,7 +172,7 @@
{ "target": "multiformats/go-multiaddr-fmt" },
{ "target": "multiformats/go-multibase" },
{ "target": "multiformats/go-multicodec" },
{ "target": "multiformats/go-multihash", "deploy_versioning": true },
{ "target": "multiformats/go-multihash" },
{ "target": "multiformats/go-multistream" },
{ "target": "multiformats/go-varint" },
{ "target": "multiformats/ma-pipe" }
Expand Down
2 changes: 1 addition & 1 deletion templates/.github/workflows/go-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
echo "RUNGOGENERATE=true" >> $GITHUB_ENV
fi
- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@df71e5d0e0ed317ebf43e6e59cf919430fa4b8f2 # 2021.1.1 (v0.2.1)
run: go install honnef.co/go/tools/cmd/staticcheck@c8caa92bad8c27ae734c6725b8a04932d54a147b # 2021.1.2 (v0.2.2)
- name: Check that go.mod is tidy
uses: protocol/multiple-go-modules@v1.2
with:
Expand Down
15 changes: 13 additions & 2 deletions templates/.github/workflows/go-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,24 @@ jobs:
run: |
go version
go env
- name: Use msys2 on windows
if: ${{ matrix.os == 'windows' }}
shell: bash
# The executable for msys2 is also called bash.cmd
# https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md#shells
# If we prepend its location to the PATH
# subsequent 'shell: bash' steps will use msys2 instead of gitbash
run: echo "C:/msys64/usr/bin" >> $GITHUB_PATH
- name: Run repo-specific setup
uses: ./.github/actions/go-test-setup
if: hashFiles('./.github/actions/go-test-setup') != ''
- name: Run tests
uses: protocol/multiple-go-modules@v1.2
with:
run: go test -v -coverprofile module-coverage.txt ./...
# Use -coverpkg=./..., so that we include cross-package coverage.
# If package ./A imports ./B, and ./A's tests also cover ./B,
# this means ./B's coverage will be significantly higher than 0%.
run: go test -v -coverprofile=module-coverage.txt -coverpkg=./... ./...
- name: Run tests (32 bit)
if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX.
uses: protocol/multiple-go-modules@v1.2
Expand All @@ -46,7 +57,7 @@ jobs:
shell: bash
run: echo "COVERAGES=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV
- name: Upload coverage to Codecov
uses: codecov/codecov-action@51d810878be5422784e86451c0e7c14e5860ec47 # v2.0.2
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
files: '${{ env.COVERAGES }}'
env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}
1 change: 0 additions & 1 deletion templates/.github/workflows/release-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Release Checker
on:
pull_request:
paths: [ 'version.json' ]
branches: [ $default-branch ]

jobs:
release-check:
Expand Down
1 change: 0 additions & 1 deletion templates/.github/workflows/releaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Releaser
on:
push:
paths: [ 'version.json' ]
branches: [ $default-branch ]

jobs:
releaser:
Expand Down

0 comments on commit 79b0229

Please sign in to comment.