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

Setting up workflows #18

Open
wants to merge 5 commits into
base: main
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
77 changes: 35 additions & 42 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
name: Release

on:
push:
branches:
- main
workflow_dispatch:

env:
REPOSITORY_OWNER: "kaytu-io"
REPOSITORY_NAME: "plugin-gcp"

jobs:
tag:
runs-on: ubuntu-latest
outputs:
latest_tag: ${{ steps.set_latest_tag.outputs.latest_tag }}
previous_tag: ${{ steps.set_latest_tag.outputs.previous_tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: stable
token: ${{ secrets.GITHUB_TOKEN }}
- name: Tag version
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GH_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
release_branches: main
tag_prefix: v
- name: Set latest tag output
Expand All @@ -35,37 +34,31 @@ jobs:
else
echo "latest_tag=${{ steps.tag_version.outputs.new_tag }}" >> "$GITHUB_OUTPUT"
fi
- name: Save new tag
id: save_new_tag
run: |
version=${{ steps.tag_version.outputs.new_tag }}
version=${version#v}
echo $version > new_tag.txt
- name: Upload new tag
uses: actions/upload-artifact@v2
echo "previous_tag=${{ steps.tag_version.outputs.previous_tag }}" >> "$GITHUB_OUTPUT"
release:
runs-on: ubuntu-latest
needs:
- tag
steps:
- name: Checkout
uses: actions/checkout@v4
with:
name: new_tag
path: new_tag.txt
# release:
# runs-on: ubuntu-latest
# needs:
# - tag
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# token: ${{ secrets.GH_TOKEN }}
# - name: Set up Go
# uses: actions/setup-go@v4
# with:
# go-version: stable
# - name: Run GoReleaser
# uses: goreleaser/goreleaser-action@v5
# with:
# distribution: goreleaser
# version: latest
# args: release --clean
# env:
# GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN}}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GORELEASER_CURRENT_TAG: ${{ needs.tag.outputs.latest_tag }}
GORELEASER_PREVIOUS_TAG: ${{ needs.tag.outputs.previous_tag }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
REPOSITORY_OWNER: ${{ env.REPOSITORY_OWNER }}
REPOSITORY_NAME: ${{ env.REPOSITORY_NAME }}
GORELEASER_MAKE_LATEST: "true"
66 changes: 66 additions & 0 deletions .github/workflows/pre-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Pre-Release

on:
workflow_dispatch:

env:
REPOSITORY_OWNER: "kaytu-io"
REPOSITORY_NAME: "plugin-gcp"

jobs:
tag:
runs-on: ubuntu-latest
outputs:
latest_tag: ${{ steps.set_latest_tag.outputs.latest_tag }}
previous_tag: ${{ steps.set_latest_tag.outputs.previous_tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Tag version
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_branches: none
pre_release_branches: main
append_to_pre_release_tag: rc
tag_prefix: v
- name: Set latest tag output
id: set_latest_tag
run: |
if [[ -z "${{ steps.tag_version.outputs.new_tag }}" ]]; then
echo "latest_tag=${{ steps.tag_version.outputs.previous_tag }}" >> "$GITHUB_OUTPUT"
else
echo "latest_tag=${{ steps.tag_version.outputs.new_tag }}" >> "$GITHUB_OUTPUT"
fi
echo "previous_tag=${{ steps.tag_version.outputs.previous_tag }}" >> "$GITHUB_OUTPUT"
release:
runs-on: ubuntu-latest
needs:
- tag
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN}}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GORELEASER_CURRENT_TAG: ${{ needs.tag.outputs.latest_tag }}
GORELEASER_PREVIOUS_TAG: ${{ needs.tag.outputs.previous_tag }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
REPOSITORY_OWNER: ${{ env.REPOSITORY_OWNER }}
REPOSITORY_NAME: ${{ env.REPOSITORY_NAME }}
GORELEASER_MAKE_LATEST: "false"
20 changes: 13 additions & 7 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,39 @@ checksum: {}

builds:
- id: linux
binary: kaytu
binary: plugin
ldflags:
- -s -w -X github.com/{{ .Env.REPOSITORY_OWNER }}/{{ .Env.REPOSITORY_NAME }}/pkg/version.VERSION={{ .Version }}
- -s -w -X github.com/{{ .Env.REPOSITORY_OWNER }}/{{ .Env.REPOSITORY_NAME }}/plugin/version.VERSION={{ .Version }}
goos:
- linux
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=0
main: ./main.go
- id: darwin
binary: kaytu
binary: plugin
ldflags:
- -s -w -X github.com/{{ .Env.REPOSITORY_OWNER }}/{{ .Env.REPOSITORY_NAME }}/pkg/version.VERSION={{ .Version }}
- -s -w -X github.com/{{ .Env.REPOSITORY_OWNER }}/{{ .Env.REPOSITORY_NAME }}/plugin/version.VERSION={{ .Version }}
goos:
- darwin
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=0
main: ./main.go
- id: windows
binary: kaytu
binary: plugin
ldflags:
- -s -w -X github.com/{{ .Env.REPOSITORY_OWNER }}/{{ .Env.REPOSITORY_NAME }}/pkg/version.VERSION={{ .Version }}
- -s -w -X github.com/{{ .Env.REPOSITORY_OWNER }}/{{ .Env.REPOSITORY_NAME }}/plugin/version.VERSION={{ .Version }}
goos:
- windows
goarch:
- amd64
env:
- CGO_ENABLED=0
main: ./main.go
archives:
- id: binary
Expand All @@ -51,4 +57,4 @@ archives:
builds: [linux]
- id: darwin
format: tar.gz
builds: [darwin]
builds: [darwin]