Skip to content
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

Expand GitHub Actions #816

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
127 changes: 123 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ jobs:

steps:
- name: Checkout branch
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{matrix.go}}

Expand Down Expand Up @@ -55,10 +57,12 @@ jobs:

steps:
- name: Checkout branch
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ${{matrix.go}}

Expand All @@ -79,3 +83,118 @@ jobs:
steps:
- name: Run Codecov
run: bash <(curl -s https://codecov.io/bash)

# Increments to the next tag on master only, bumps version based on the recent commits
new_tag:
if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && github.event_name == 'push'
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Get next version
id: new_git_tag
run: |
git remote add upstream https://github.com/gocolly/colly || true
git fetch upstream --tags
git tag # This is just for future debug, lists the past tags
go install github.com/caarlos0/svu@latest
NEW_TAG=$(svu next --tag-mode all-branches --force-patch-increment)
echo "Using the next tag of ${NEW_TAG} for this release"
echo "new_tag=$NEW_TAG" >> $GITHUB_ENV
echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT
outputs:
new_tag: ${{ steps.new_git_tag.outputs.new_tag }}

# Creates a new release page on GitHub when master changes
create_release:
if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && github.event_name == 'push'
runs-on: ubuntu-latest
needs: new_tag
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create Release
id: create_release
uses: actions/create-release@v1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action seems to be unmaintained, I wouldn't use it: https://github.com/actions/create-release

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe try this fork instead for now: https://github.com/marketplace/actions/gh-release

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.new_tag.outputs.new_tag }}
release_name: Release ${{ needs.new_tag.outputs.new_tag }}
draft: false
prerelease: false
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}

# In this Release section, we are re-building the binaries because eventually we can include the new git tag as their
# version string when saying 'colly --version'
build_and_upload:
if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && github.event_name == 'push'
runs-on: ubuntu-latest
needs: [test, new_tag, create_release]
strategy:
matrix:
include:
- target: linux-i386
goos: linux
goarch: 386
- target: linux-x86_64
goos: linux
goarch: amd64
- target: linux-armv6
goos: linux
goarch: arm
goarm: 6
- target: linux-armv7
goos: linux
goarch: arm
goarm: 7
- target: linux-arm64
goos: linux
goarch: arm64
- target: linux-riscv64
goos: linux
goarch: riscv64
- target: darwin-x86_64
goos: darwin
goarch: amd64
- target: darwin-arm64
goos: darwin
goarch: arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Build binaries
env:
TARGET: ${{ matrix.target }}
GOARCH: ${{ matrix.goarch }}
GOOS: ${{ matrix.goos }}
GOARM: ${{ matrix.goarm }}
run: |
OUT_DIR=dist/colly-$TARGET
mkdir -p $OUT_DIR
go build -o $OUT_DIR/colly ./cmd/colly
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./dist/colly-${{ matrix.target }}/colly
asset_name: colly-${{ matrix.target }}/colly
asset_content_type: application/octet-stream
32 changes: 20 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
module github.com/gocolly/colly/v2

go 1.12
go 1.19

require (
github.com/PuerkitoBio/goquery v1.5.1
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/antchfx/htmlquery v1.2.3
github.com/antchfx/xmlquery v1.3.4
github.com/PuerkitoBio/goquery v1.9.2
github.com/antchfx/htmlquery v1.3.1
github.com/antchfx/xmlquery v1.4.0
github.com/gobwas/glob v0.2.3
github.com/jawher/mow.cli v1.1.0
github.com/jawher/mow.cli v1.2.0
github.com/kennygrant/sanitize v1.2.4
github.com/nlnwa/whatwg-url v0.1.2
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca
github.com/temoto/robotstxt v1.1.1
golang.org/x/net v0.17.0
google.golang.org/appengine v1.6.6
google.golang.org/protobuf v1.33.0 // indirect
github.com/nlnwa/whatwg-url v0.4.1
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d
github.com/temoto/robotstxt v1.1.2
golang.org/x/net v0.25.0
google.golang.org/appengine v1.6.8
)

require (
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/antchfx/xpath v1.3.0 // indirect
github.com/bits-and-blooms/bitset v1.13.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
)
Loading