forked from hashicorp/consul
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: new release workflow based on tags
Release criteo1 version for test purpose.
- Loading branch information
Mathias Brulatout
committed
Jun 19, 2024
1 parent
de46691
commit b92d9d1
Showing
2 changed files
with
151 additions
and
1 deletion.
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,150 @@ | ||
name: create-release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*-criteo*' | ||
|
||
permissions: | ||
contents: write | ||
|
||
env: | ||
PKG_NAME: consul | ||
METADATA: oss | ||
|
||
jobs: | ||
get-go-version: | ||
uses: ./.github/workflows/reusable-get-go-version.yml | ||
|
||
set-product-version: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
product-version: ${{ steps.set-product-version.outputs.product-version }} | ||
base-product-version: ${{ steps.set-product-version.outputs.base-product-version }} | ||
product-date: ${{ steps.get-product-version.outputs.product-date }} | ||
pre-version: ${{ steps.set-product-version.outputs.prerelease-product-version }} | ||
shared-ldflags: ${{ steps.shared-ldflags.outputs.shared-ldflags }} | ||
steps: | ||
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | ||
# action-set-product-version implicitly sets fields like 'product-version' using version/VERSION | ||
# https://github.com/hashicorp/actions-set-product-version | ||
- name: set product version | ||
id: set-product-version | ||
uses: hashicorp/actions-set-product-version@v2 | ||
- name: get product version | ||
id: get-product-version | ||
run: | | ||
CONSUL_DATE=$(build-support/scripts/build-date.sh) | ||
echo "product-date=${CONSUL_DATE}" >> "$GITHUB_OUTPUT" | ||
- name: Set shared -ldflags | ||
id: shared-ldflags | ||
run: | | ||
T="github.com/hashicorp/consul/version" | ||
echo "shared-ldflags=-X ${T}.GitCommit=${GITHUB_SHA::8} \ | ||
-X ${T}.GitDescribe=${{ steps.set-product-version.outputs.product-version }} \ | ||
-X ${T}.BuildDate=${{ steps.get-product-version.outputs.product-date }} \ | ||
-X ${T}.VersionPrerelease=${{ steps.set-product-version.outputs.pre-version }} \ | ||
" >> "$GITHUB_OUTPUT" | ||
validate-outputs: | ||
needs: set-product-version | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Validate Outputs | ||
run: | | ||
echo "Product Version: ${{ needs.set-product-version.outputs.product-version }}" | ||
echo "Base Product Version: ${{ needs.set-product-version.outputs.base-product-version }}" | ||
echo "Product Metadata: ${{ env.METADATA }}" | ||
echo "Product Date: ${{ needs.set-product-version.outputs.product-date }}" | ||
echo "Prerelease Version: ${{ needs.set-product-version.outputs.pre-version }}" | ||
echo "Ldflags: ${{ needs.set-product-version.outputs.shared-ldflags }}" | ||
generate-metadata-file: | ||
needs: set-product-version | ||
runs-on: ubuntu-latest | ||
outputs: | ||
filepath: ${{ steps.generate-metadata-file.outputs.filepath }} | ||
steps: | ||
- name: 'Checkout directory' | ||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | ||
- name: Generate metadata file | ||
id: generate-metadata-file | ||
uses: hashicorp/actions-generate-metadata@v1 | ||
with: | ||
version: ${{ needs.set-product-version.outputs.product-version }} | ||
product: ${{ env.PKG_NAME }} | ||
|
||
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 | ||
with: | ||
name: metadata.json | ||
path: ${{ steps.generate-metadata-file.outputs.filepath }} | ||
|
||
build: | ||
needs: | ||
- set-product-version | ||
- get-go-version | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
include: | ||
- {goos: "linux", goarch: "amd64"} | ||
- {goos: "linux", goarch: "arm64"} | ||
- {goos: "windows", goarch: "amd64"} | ||
fail-fast: true | ||
|
||
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build | ||
steps: | ||
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | ||
|
||
- name: Go Build | ||
env: | ||
PRODUCT_VERSION: ${{ needs.set-product-version.outputs.product-version }} | ||
PRERELEASE_VERSION: ${{ needs.set-product-version.outputs.pre-version }} | ||
CGO_ENABLED: "0" | ||
GOLDFLAGS: "${{needs.set-product-version.outputs.shared-ldflags}}" | ||
run: | | ||
mkdir -p ./out | ||
go build -ldflags="$GOLDFLAGS" -o ./out/consul_${{ matrix.goos }}_${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }} | ||
echo "output files : " && find ./out | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: consul_${{ matrix.goos }}_${{ matrix.goarch }} | ||
path: ./out/consul* | ||
|
||
create-release: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- uses: actions/download-artifact@v4 | ||
with: | ||
path: artifacts | ||
- name: Display structure of downloaded files | ||
run: ls -R artifacts | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
body: | | ||
Release notes for ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
# | ||
# - name: Upload check | ||
# run: | | ||
# echo "Will upload these files ..." && find ./out | ||
# | ||
- name: Upload | ||
uses: fnkr/github-action-ghr@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GHR_PATH: artifacts/ | ||
GHR_COMPRESS: gz |
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 +1 @@ | ||
1.18.2 | ||
1.18.2-criteo1 |