Skip to content

Commit

Permalink
chore(ci): migrate to release-please (#1215)
Browse files Browse the repository at this point in the history
  • Loading branch information
noahdietz authored Aug 1, 2023
1 parent 9f778ae commit 99265d7
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 302 deletions.
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
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

0 comments on commit 99265d7

Please sign in to comment.