diff --git a/.github/workflows/release-artifacts-manually.yml b/.github/workflows/release-artifacts-manually.yml new file mode 100644 index 0000000000..08937f8850 --- /dev/null +++ b/.github/workflows/release-artifacts-manually.yml @@ -0,0 +1,15 @@ +name: release-artifacts-manually + +on: + workflow_dispatch: + inputs: + tag: + type: string + required: true + description: tag + +jobs: + release-artifacts: + uses: ./.github/workflows/release-artifacts.yml + with: + tag: ${{ github.event.inputs.tag }} diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml new file mode 100644 index 0000000000..59917fdd0b --- /dev/null +++ b/.github/workflows/release-artifacts.yml @@ -0,0 +1,138 @@ +name: release-artifacts + +on: + workflow_call: + inputs: + tag: + required: false + type: string + +jobs: + osx-build: + runs-on: macos-12 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + # copy the newest version env.sh before switching version. + - name: Copy Env Script + shell: bash + run: | + cp -r ci/env.sh /tmp/env.sh + + - name: Switch Version + if: ${{ inputs.tag }} + run: | + git checkout ${{ inputs.tag }} + + - name: Build + shell: bash + run: | + brew install coreutils + PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" + brew install gnu-tar + PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" + source /tmp/env.sh + ci/publish-tarball.sh + mkdir -p "github-action-s3-upload/${{ inputs.tag }}" + cp -v "solana-release-x86_64-apple-darwin.tar.bz2" "github-action-s3-upload/${{ inputs.tag }}/" + cp -v "solana-release-x86_64-apple-darwin.yml" "github-action-s3-upload/${{ inputs.tag }}/" + cp -v "solana-install-init-x86_64-apple-darwin"* "github-action-s3-upload/${{ inputs.tag }}/" + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: osx-artifact + path: github-action-s3-upload/ + + osx-s3-upload: + needs: [osx-build] + runs-on: ubuntu-20.04 + steps: + - name: Download + uses: actions/download-artifact@v3 + with: + name: osx-artifact + path: ./github-action-s3-upload + + - name: Upload + uses: jakejarvis/s3-sync-action@master + with: + args: --acl public-read --follow-symlinks --delete + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} + AWS_REGION: "us-west-1" + SOURCE_DIR: "github-action-s3-upload" + + windows-build: + runs-on: windows-2022 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + # copy the newest version env.sh before switching version. + - name: Copy Env Script + shell: bash + run: | + cp -r ci/env.sh /tmp/env.sh + + - name: Switch Version + if: ${{ inputs.tag }} + run: | + git checkout ${{ inputs.tag }} + + - name: Build + shell: bash + run: | + choco install openssl + export OPENSSL_DIR="C:\Program Files\OpenSSL-Win64" + choco install protoc + source /tmp/env.sh + 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: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: windows-artifact + path: github-action-s3-upload/ + + windows-s3-upload: + needs: [windows-build] + runs-on: ubuntu-20.04 + steps: + - name: Download + uses: actions/download-artifact@v3 + with: + name: windows-artifact + path: ./github-action-s3-upload + + - name: Upload + uses: jakejarvis/s3-sync-action@master + with: + args: --acl public-read --follow-symlinks --delete + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} + AWS_REGION: "us-west-1" + SOURCE_DIR: "github-action-s3-upload" diff --git a/ci/env.sh b/ci/env.sh index 8d1902e063..35f8bc7545 100644 --- a/ci/env.sh +++ b/ci/env.sh @@ -81,6 +81,42 @@ if [[ -n $CI ]]; then fi export CI_REPO_SLUG=$APPVEYOR_REPO_NAME export CI_TAG=$APPVEYOR_REPO_TAG_NAME + + elif [[ $GITHUB_ACTION ]]; then + export CI_BUILD_ID=$GITHUB_RUN_ID + export CI_JOB_ID=$GITHUB_RUN_NUMBER + export CI_REPO_SLUG=$GITHUB_REPOSITORY + + 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 + + if [[ $GITHUB_BASE_REF ]]; then + export CI_BASE_BRANCH=$GITHUB_BASE_REF + export CI_PULL_REQUEST=true + fi + + case $RUNNER_OS in + macOS) + export CI_OS_NAME=osx + ;; + Windows) + export CI_OS_NAME=windows + ;; + Linux) + export CI_OS_NAME=linux + ;; + *) + ;; + esac fi else export CI= diff --git a/ci/publish-tarball.sh b/ci/publish-tarball.sh index ef46c60eff..3a5cc25a4e 100755 --- a/ci/publish-tarball.sh +++ b/ci/publish-tarball.sh @@ -136,6 +136,14 @@ for file in "${TARBALL_BASENAME}"-$TARGET.tar.bz2 "${TARBALL_BASENAME}"-$TARGET. mkdir -p travis-release-upload/ cp -v "$file" travis-release-upload/ fi + elif [[ -n $GITHUB_ACTIONS ]]; then + mkdir -p github-action-s3-upload/"$CHANNEL_OR_TAG" + cp -v "$file" github-action-s3-upload/"$CHANNEL_OR_TAG"/ + + if [[ -n $TAG ]]; then + mkdir -p github-action-release-upload/ + cp -v "$file" github-action-release-upload/ + fi elif [[ -n $APPVEYOR ]]; then # Add artifacts for .appveyor.yml to upload appveyor PushArtifact "$file" -FileName "$CHANNEL_OR_TAG"/"$file"