-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: package releases for different operating systems (#71)
- Loading branch information
Showing
5 changed files
with
171 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
name: Package this version | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
snapshot: | ||
name: Save a snapshot | ||
if: ${{ ! startsWith(github.ref, 'refs/tags/') }} | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{ steps.tag.outputs.version }} | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Go environment | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.21.x' | ||
- name: Create snapshots | ||
uses: goreleaser/goreleaser-action@v5 | ||
with: | ||
args: release --clean --snapshot --skip=publish | ||
- name: Collect the current version | ||
id: tag | ||
run: | | ||
echo "version=$(git describe --dirty --always --tags)" >> "$GITHUB_ENV" | ||
echo "version=$(git describe --dirty --always --tags)" >> "$GITHUB_OUTPUT" | ||
- name: Upload the checksums | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: etime_${{ env.version }}_checksums.txt | ||
path: ./dist/etime_${{ env.version }}_checksums.txt | ||
- name: Cache the moments | ||
uses: actions/cache/save@v3 | ||
if: always() | ||
with: | ||
path: ./dist | ||
key: snapshots-${{ github.sha }} | ||
|
||
artifacts: | ||
name: Share the artifacts | ||
needs: snapshot | ||
runs-on: ubuntu-latest | ||
env: | ||
version: ${{ needs.snapshot.outputs.version }} | ||
strategy: | ||
matrix: | ||
target: | ||
- darwin_arm64.tar.gz | ||
- darwin_x86_64.tar.gz | ||
- linux_arm64.tar.gz | ||
- linux_i386.tar.gz | ||
- linux_x86_64.tar.gz | ||
- windows_arm64.zip | ||
- windows_i386.zip | ||
- windows_x86_64.zip | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@v4 | ||
- name: Restore cached snapshots | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: ./dist | ||
key: snapshots-${{ github.sha }} | ||
- name: Upload a snapshot | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: etime_${{ env.version }}_${{ matrix.target }} | ||
path: ./dist/etime_${{ env.version }}_${{ matrix.target }} | ||
|
||
notify: | ||
name: Post a notification | ||
needs: artifacts | ||
if: github.event_name == 'pull_request' | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
steps: | ||
- name: Leave a comment | ||
run: | | ||
PR_COMMENT="Latest builds: https://github.com/$GH_REPO/actions/runs/$GH_RUN_ID" | ||
PR_REF="${{ github.ref_name }}" | ||
if [[ $PR_REF == *"/merge" ]]; then | ||
PR_REF="${PR_REF%%/merge}" | ||
fi | ||
if ! gh pr comment "$PR_REF" --repo "$GH_REPO" --edit-last --body "$PR_COMMENT"; then | ||
gh pr comment "$PR_REF" --repo "$GH_REPO" --body "$PR_COMMENT" | ||
fi | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
GH_REPO: ${{ github.repository }} | ||
GH_RUN_ID: ${{ github.run_id }} | ||
|
||
release: | ||
name: Distribute a release | ||
if: ${{ startsWith(github.ref, 'refs/tags/') }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Go environment | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.21.x' | ||
- name: Create releases | ||
uses: goreleaser/goreleaser-action@v5 | ||
with: | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# binary | ||
# Built binaries | ||
etime | ||
dist/* | ||
|
||
# development | ||
# Development leftovers | ||
*.swp | ||
.github/runner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json | ||
version: 1 | ||
|
||
before: | ||
hooks: | ||
- go mod tidy | ||
|
||
builds: | ||
- id: etime | ||
binary: etime_{{.Summary}} | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
|
||
archives: | ||
- format: tar.gz | ||
name_template: >- | ||
etime_ | ||
{{- .Summary }}_ | ||
{{- .Os }}_ | ||
{{- if eq .Arch "amd64" }}x86_64 | ||
{{- else if eq .Arch "386" }}i386 | ||
{{- else }}{{ .Arch }}{{ end }} | ||
{{- if .Arm }}v{{ .Arm }}{{ end }} | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
|
||
changelog: | ||
skip: true | ||
|
||
checksum: | ||
name_template: "etime_{{ .Summary }}_checksums.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters