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

refactor: release workflow #447

Merged
merged 1 commit into from
Nov 19, 2024
Merged
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
40 changes: 23 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: Checkout Console
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
Expand All @@ -42,48 +47,49 @@ jobs:
- name: move files
run: mv ./temp/ui/* ./internal/controller/http/ui

- uses: actions/setup-go@v5
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: ">=1.23.0"
- name: 🔬 Check semantic versioning
id: semantic-release
env:
GITHUB_REF: ${{ github.head_ref }}
run: |
GITHUB_REF=${{ github.head_ref }}
npx semantic-release --no-ci --dry-run --plugins @semantic-release/commit-analyzer --branches ${{ github.head_ref }}
VERSION=$(cat .VERSION)

npx semantic-release --no-ci --dry-run --plugins @semantic-release/commit-analyzer --branches $GITHUB_REF
VERSION=$(cat .VERSION)

- shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
#build linux
#build linux
- shell: bash
if: matrix.os == 'ubuntu-latest'
run: |
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X 'github.com/open-amt-cloud-toolkit/console/internal/app.Version=$VERSION'" -trimpath -o dist/linux/console_linux_x64 ./cmd/app/main.go
- shell: bash

- shell: bash
if: matrix.os == 'windows-latest'
run: |
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -X 'github.com/open-amt-cloud-toolkit/console/internal/app.Version=$VERSION'" -trimpath -o dist/windows/console_windows_x64 ./cmd/app/main.go

- shell: bash
if: matrix.os == 'macos-latest'
run: |
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w -X 'github.com/open-amt-cloud-toolkit/console/internal/app.Version=$VERSION'" -trimpath -o dist/farwin/console_mac_arm64 ./cmd/app/main.go
- uses: actions/cache@v4

- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
if: matrix.os == 'ubuntu-latest'
with:
path: dist/linux
key: linux-${{ env.sha_short }}

- uses: actions/cache@v4
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
if: matrix.os == 'macos-latest'
with:
path: dist/darwin
key: darwin-${{ env.sha_short }}

- uses: actions/cache@v4
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
if: matrix.os == 'windows-latest'
with:
path: dist/windows
Expand All @@ -105,15 +111,15 @@ jobs:
- shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- uses: actions/[email protected]
- uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3.2.3
with:
path: dist/linux
key: linux-${{ env.sha_short }}
- uses: actions/[email protected]
- uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3.2.3
with:
path: dist/darwin
key: darwin-${{ env.sha_short }}
- uses: actions/[email protected]
- uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3.2.3
with:
path: dist/windows
key: windows-${{ env.sha_short }}
Expand Down Expand Up @@ -147,7 +153,7 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
logout: true

- name: Semantic Release
uses: cycjimmy/semantic-release-action@b1b432f13acb7768e0c8efdec416d363a57546f2 # v4.1.1
if: steps.cache.outputs.cache-hit != 'true' # do not run if cache hit
Expand Down
Loading