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

chore(ci): migrate to release-please #1215

Merged
merged 2 commits into from
Aug 1, 2023
Merged
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
5 changes: 5 additions & 0 deletions .github/release-please.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
handleGHRelease: true
manifest: true
manifestFile: .release-please-manifest.json
manifestConfig: .release-please-config.json
releaseType: go-yoshi
124 changes: 0 additions & 124 deletions .github/release-tool/changelog.go

This file was deleted.

58 changes: 0 additions & 58 deletions .github/release-tool/main.go

This file was deleted.

62 changes: 0 additions & 62 deletions .github/release-tool/version.go

This file was deleted.

61 changes: 15 additions & 46 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,46 +1,17 @@
---
name: release
on:
schedule:
- cron: 0 20 * * 3 # Wednesdays at 20:00 UTC
workflow_dispatch: {} # Allow manual triggering
jobs:
inspect:
runs-on: ubuntu-latest
container: golang:1.20
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get release information
id: release_tool
run: go run ./.github/release-tool/
outputs:
version: ${{ steps.release_tool.outputs.version }}
release_notes: ${{ steps.release_tool.outputs.release_notes }}
release:
runs-on: ubuntu-latest
needs: inspect
if: ${{ needs.inspect.outputs.version }}
steps:
- name: Create the GitHub release.
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: v${{ needs.inspect.outputs.version }}
release_name: api-linter ${{ needs.inspect.outputs.version }}
body: ${{ needs.inspect.outputs.release_notes }}
draft: false
prerelease: false
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
types:
- created

env:
# e.g. v1.0.0
TAG_NAME: ${{ github.event.release.tag_name }}

jobs:
build:
runs-on: ubuntu-latest
needs:
- inspect
- release
strategy:
matrix:
osarch:
Expand All @@ -57,7 +28,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.18"
go-version-file: 'go.mod'
- uses: actions/checkout@v3
# The API linter does not use these, but we need them to build the
# binaries.
Expand All @@ -71,22 +42,20 @@ jobs:
run: |
go install github.com/mitchellh/gox@latest
go get github.com/inconshreveable/mousetrap
- name: Set the version number in the binary (for `api-linter --version`).
run: |
cat > cmd/api-linter/version.go <<EOF
package main
const version = "${{ needs.inspect.outputs.version }}"
EOF
- name: Build for the ${{ matrix.osarch.os }}/${{ matrix.osarch.arch }} platform.
run: |
gox -osarch ${{ matrix.osarch.os }}/${{ matrix.osarch.arch }} -output api-linter ./... && \
tar cvfz api-linter.tar.gz api-linter*
- name: Set raw version
id: raw_tag
# Strips the 'v' from the actual semver version.
run: echo ::set-output name=raw_version::"${TAG_NAME#v}"
- name: Upload the ${{ matrix.osarch.os }}/${{ matrix.osarch.arch }} release.
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./api-linter.tar.gz
asset_name: api-linter-${{ needs.inspect.outputs.version }}-${{ matrix.osarch.os }}-${{ matrix.osarch.arch }}.tar.gz
asset_name: api-linter-${{ steps.raw_tag.outputs.raw_version }}-${{ matrix.osarch.os }}-${{ matrix.osarch.arch }}.tar.gz
asset_content_type: application/tar+gzip
10 changes: 10 additions & 0 deletions .release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"release-type": "go-yoshi",
"include-component-in-tag": false,
"include-v-in-tag": true,
"packages": {
".": {
"component": "api-linter"
}
}
}
3 changes: 3 additions & 0 deletions .release-please-manfiest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "1.55.0"
}
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Changelog
Copy link
Contributor

Choose a reason for hiding this comment

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

any way to change the name to CHANGELOG.md? I think that's more common.

3 changes: 2 additions & 1 deletion cmd/api-linter/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"sync"

dpb "github.com/golang/protobuf/protoc-gen-go/descriptor"
"github.com/googleapis/api-linter/internal"
"github.com/googleapis/api-linter/lint"
"github.com/jhump/protoreflect/desc"
"github.com/jhump/protoreflect/desc/protoparse"
Expand Down Expand Up @@ -108,7 +109,7 @@ func newCli(args []string) *cli {
func (c *cli) lint(rules lint.RuleRegistry, configs lint.Configs) error {
// Print version and exit if asked.
if c.VersionFlag {
fmt.Printf("api-linter %s\n", version)
fmt.Printf("api-linter %s\n", internal.Version)
return nil
}

Expand Down
Loading