chore: build windows artifacts on Github Actions (#25188)

* chore: always checkout repo from master

* chore: rename variable tag => commit

* chore: gh-release when tag is present

* chore: add release-artifacts-auto

* chore: skip build when channel is empty

* chore: use GITHUB_REF_NAME as CI_BRANCH
This commit is contained in:
Yihau Chen 2022-05-13 17:10:03 +08:00 committed by GitHub
parent e024806aa5
commit e493e0033a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 18 deletions

View File

@ -0,0 +1,19 @@
name: release-artifacts-auto
on:
push:
branches:
- master
- v[0-9]+.[0-9]+
tags:
- v[0-9]+.[0-9]+.[0-9]
jobs:
release-artifacts:
uses: ./.github/workflows/release-artifacts.yml
with:
commit: ${{ github.sha }}
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}

View File

@ -3,16 +3,16 @@ name: release-artifacts-manually
on:
workflow_dispatch:
inputs:
tag:
commit:
type: string
required: true
description: tag
description: commit
jobs:
release-artifacts:
uses: ./.github/workflows/release-artifacts.yml
with:
tag: ${{ github.event.inputs.tag }}
commit: ${{ github.event.inputs.commit }}
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

View File

@ -3,7 +3,7 @@ name: release-artifacts
on:
workflow_call:
inputs:
tag:
commit:
required: false
type: string
secrets:
@ -17,10 +17,14 @@ on:
jobs:
windows-build:
runs-on: windows-2022
outputs:
tag: ${{ steps.build.outputs.tag }}
channel: ${{ steps.build.outputs.channel }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: master
fetch-depth: 0
- name: Setup Rust
@ -35,30 +39,41 @@ jobs:
cp -r ci/env.sh /tmp/env.sh
- name: Switch Version
if: ${{ inputs.tag }}
if: ${{ inputs.commit }}
run: |
git checkout ${{ inputs.tag }}
git checkout ${{ inputs.commit }}
- name: Build
id: build
shell: bash
run: |
choco install openssl
export OPENSSL_DIR="C:\Program Files\OpenSSL-Win64"
choco install protoc
source /tmp/env.sh
echo "::set-output name=tag::$CI_TAG"
eval "$(ci/channel-info.sh)"
echo "::set-output name=channel::$CHANNEL"
ci/publish-tarball.sh
mkdir -p "github-action-s3-upload/${{ inputs.tag }}"
cp -v "solana-release-x86_64-pc-windows-msvc.tar.bz2" "github-action-s3-upload/${{ inputs.tag }}/"
cp -v "solana-release-x86_64-pc-windows-msvc.yml" "github-action-s3-upload/${{ inputs.tag }}/"
cp -v "solana-install-init-x86_64-pc-windows-msvc"* "github-action-s3-upload/${{ inputs.tag }}/"
- name: Prepare Upload Files
if: ${{ steps.build.outputs.channel != '' || steps.build.outputs.tag != '' }}
shell: bash
run: |
mkdir -p "github-action-s3-upload/${{ inputs.commit }}"
cp -v "solana-release-x86_64-pc-windows-msvc.tar.bz2" "github-action-s3-upload/${{ inputs.commit }}/"
cp -v "solana-release-x86_64-pc-windows-msvc.yml" "github-action-s3-upload/${{ inputs.commit }}/"
cp -v "solana-install-init-x86_64-pc-windows-msvc"* "github-action-s3-upload/${{ inputs.commit }}/"
- name: Upload Artifacts
if: ${{ steps.build.outputs.channel != '' || steps.build.outputs.tag != '' }}
uses: actions/upload-artifact@v3
with:
name: windows-artifact
path: github-action-s3-upload/
windows-s3-upload:
if: ${{ needs.windows-build.outputs.channel != '' || needs.windows-build.outputs.tag != '' }}
needs: [windows-build]
runs-on: ubuntu-20.04
steps:
@ -80,6 +95,7 @@ jobs:
SOURCE_DIR: "github-action-s3-upload"
windows-gh-release:
if: ${{ needs.windows-build.outputs.tag != '' }}
needs: [windows-build]
runs-on: ubuntu-20.04
steps:
@ -92,7 +108,7 @@ jobs:
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ inputs.tag }}
tag_name: ${{ inputs.commit }}
draft: true
files: |
github-action-s3-upload/${{ inputs.tag }}/*
github-action-s3-upload/${{ inputs.commit }}/*

View File

@ -86,16 +86,11 @@ if [[ -n $CI ]]; then
export CI_BUILD_ID=$GITHUB_RUN_ID
export CI_JOB_ID=$GITHUB_RUN_NUMBER
export CI_REPO_SLUG=$GITHUB_REPOSITORY
export CI_BRANCH=$GITHUB_REF_NAME
CI_COMMIT=$(git rev-parse HEAD)
export CI_COMMIT
CI_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ $CI_BRANCH == "HEAD" ]]; then
CI_BRANCH=""
fi
export CI_BRANCH
CI_TAG=$(git tag --points-at HEAD)
export CI_TAG