mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-05-19 09:40:22 -07:00
ci: re-work github actions release
This combines the tips from #1820 and the patch submitted in #1675. The latter wasn't taken as-is because I didn't agree with some of the changes, and in particular, it removed the ability to easily test the release on a branch with a dummy tag name. I've tried to add that back here with the 'rg_version' output. Overall though, using outputs is indeed much simpler. Closes #1675, Closes #1820
This commit is contained in:
parent
e48a17e189
commit
df83b8b444
67
.github/workflows/release.yml
vendored
67
.github/workflows/release.yml
vendored
@ -1,23 +1,26 @@
|
|||||||
# The way this works is a little weird. But basically, the create-release job
|
# The way this works is the following:
|
||||||
# runs purely to initialize the GitHub release itself. Once done, the upload
|
|
||||||
# URL of the release is saved as an artifact.
|
|
||||||
#
|
#
|
||||||
# The build-release job runs only once create-release is finished. It gets
|
# The create-release job runs purely to initialize the GitHub release itself
|
||||||
# the release upload URL by downloading the corresponding artifact (which was
|
# and to output upload_url for the following job.
|
||||||
# uploaded by create-release). It then builds the release executables for each
|
#
|
||||||
# supported platform and attaches them as release assets to the previously
|
# The build-release job runs only once create-release is finished. It gets the
|
||||||
# created release.
|
# release upload URL from create-release job outputs, then builds the release
|
||||||
|
# executables for each supported platform and attaches them as release assets
|
||||||
|
# to the previously created release.
|
||||||
#
|
#
|
||||||
# The key here is that we create the release only once.
|
# The key here is that we create the release only once.
|
||||||
|
#
|
||||||
|
# Reference:
|
||||||
|
# https://eugene-babichenko.github.io/blog/2020/05/09/github-actions-cross-platform-auto-releases/
|
||||||
|
|
||||||
name: release
|
name: release
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
# Enable when testing release infrastructure on a branch.
|
# Enable when testing release infrastructure on a branch.
|
||||||
# branches:
|
# branches:
|
||||||
# - ag/release
|
# - ag/work
|
||||||
tags:
|
tags:
|
||||||
- '[0-9]+.[0-9]+.[0-9]+'
|
- "[0-9]+.[0-9]+.[0-9]+"
|
||||||
jobs:
|
jobs:
|
||||||
create-release:
|
create-release:
|
||||||
name: create-release
|
name: create-release
|
||||||
@ -25,11 +28,12 @@ jobs:
|
|||||||
# env:
|
# env:
|
||||||
# Set to force version number, e.g., when no tag exists.
|
# Set to force version number, e.g., when no tag exists.
|
||||||
# RG_VERSION: TEST-0.0.0
|
# RG_VERSION: TEST-0.0.0
|
||||||
|
outputs:
|
||||||
|
upload_url: ${{ steps.release.outputs.upload_url }}
|
||||||
|
rg_version: ${{ env.RG_VERSION }}
|
||||||
steps:
|
steps:
|
||||||
- name: Create artifacts directory
|
|
||||||
run: mkdir artifacts
|
|
||||||
|
|
||||||
- name: Get the release version from the tag
|
- name: Get the release version from the tag
|
||||||
|
shell: bash
|
||||||
if: env.RG_VERSION == ''
|
if: env.RG_VERSION == ''
|
||||||
run: |
|
run: |
|
||||||
# Apparently, this is the right way to get a tag name. Really?
|
# Apparently, this is the right way to get a tag name. Really?
|
||||||
@ -37,7 +41,6 @@ jobs:
|
|||||||
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
|
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
|
||||||
echo "RG_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
echo "RG_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
||||||
echo "version is: ${{ env.RG_VERSION }}"
|
echo "version is: ${{ env.RG_VERSION }}"
|
||||||
|
|
||||||
- name: Create GitHub release
|
- name: Create GitHub release
|
||||||
id: release
|
id: release
|
||||||
uses: actions/create-release@v1
|
uses: actions/create-release@v1
|
||||||
@ -47,18 +50,6 @@ jobs:
|
|||||||
tag_name: ${{ env.RG_VERSION }}
|
tag_name: ${{ env.RG_VERSION }}
|
||||||
release_name: ${{ env.RG_VERSION }}
|
release_name: ${{ env.RG_VERSION }}
|
||||||
|
|
||||||
- name: Save release upload URL to artifact
|
|
||||||
run: echo "${{ steps.release.outputs.upload_url }}" > artifacts/release-upload-url
|
|
||||||
|
|
||||||
- name: Save version number to artifact
|
|
||||||
run: echo "${{ env.RG_VERSION }}" > artifacts/release-version
|
|
||||||
|
|
||||||
- name: Upload artifacts
|
|
||||||
uses: actions/upload-artifact@v1
|
|
||||||
with:
|
|
||||||
name: artifacts
|
|
||||||
path: artifacts
|
|
||||||
|
|
||||||
build-release:
|
build-release:
|
||||||
name: build-release
|
name: build-release
|
||||||
needs: ['create-release']
|
needs: ['create-release']
|
||||||
@ -68,7 +59,7 @@ jobs:
|
|||||||
# systems.
|
# systems.
|
||||||
CARGO: cargo
|
CARGO: cargo
|
||||||
# When CARGO is set to CROSS, this is set to `--target matrix.target`.
|
# When CARGO is set to CROSS, this is set to `--target matrix.target`.
|
||||||
TARGET_FLAGS:
|
TARGET_FLAGS: ""
|
||||||
# When CARGO is set to CROSS, TARGET_DIR includes matrix.target.
|
# When CARGO is set to CROSS, TARGET_DIR includes matrix.target.
|
||||||
TARGET_DIR: ./target
|
TARGET_DIR: ./target
|
||||||
# Emit backtraces on panics.
|
# Emit backtraces on panics.
|
||||||
@ -129,7 +120,7 @@ jobs:
|
|||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Use Cross
|
- name: Use Cross
|
||||||
# if: matrix.os != 'windows-2019'
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cargo install cross
|
cargo install cross
|
||||||
echo "CARGO=cross" >> $GITHUB_ENV
|
echo "CARGO=cross" >> $GITHUB_ENV
|
||||||
@ -142,22 +133,6 @@ jobs:
|
|||||||
echo "target flag is: ${{ env.TARGET_FLAGS }}"
|
echo "target flag is: ${{ env.TARGET_FLAGS }}"
|
||||||
echo "target dir is: ${{ env.TARGET_DIR }}"
|
echo "target dir is: ${{ env.TARGET_DIR }}"
|
||||||
|
|
||||||
- name: Get release download URL
|
|
||||||
uses: actions/download-artifact@v1
|
|
||||||
with:
|
|
||||||
name: artifacts
|
|
||||||
path: artifacts
|
|
||||||
|
|
||||||
- name: Set release upload URL and release version
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
release_upload_url="$(cat artifacts/release-upload-url)"
|
|
||||||
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV
|
|
||||||
echo "release upload url: $RELEASE_UPLOAD_URL"
|
|
||||||
release_version="$(cat artifacts/release-version)"
|
|
||||||
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
|
|
||||||
echo "release version: $RELEASE_VERSION"
|
|
||||||
|
|
||||||
- name: Build release binary
|
- name: Build release binary
|
||||||
run: ${{ env.CARGO }} build --verbose --release --features pcre2 ${{ env.TARGET_FLAGS }}
|
run: ${{ env.CARGO }} build --verbose --release --features pcre2 ${{ env.TARGET_FLAGS }}
|
||||||
|
|
||||||
@ -178,7 +153,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
outdir="$(ci/cargo-out-dir "${{ env.TARGET_DIR }}")"
|
outdir="$(ci/cargo-out-dir "${{ env.TARGET_DIR }}")"
|
||||||
staging="ripgrep-${{ env.RELEASE_VERSION }}-${{ matrix.target }}"
|
staging="ripgrep-${{ needs.create-release.outputs.rg_version }}-${{ matrix.target }}"
|
||||||
mkdir -p "$staging"/{complete,doc}
|
mkdir -p "$staging"/{complete,doc}
|
||||||
|
|
||||||
cp {README.md,COPYING,UNLICENSE,LICENSE-MIT} "$staging/"
|
cp {README.md,COPYING,UNLICENSE,LICENSE-MIT} "$staging/"
|
||||||
@ -203,7 +178,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
|
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||||
asset_path: ${{ env.ASSET }}
|
asset_path: ${{ env.ASSET }}
|
||||||
asset_name: ${{ env.ASSET }}
|
asset_name: ${{ env.ASSET }}
|
||||||
asset_content_type: application/octet-stream
|
asset_content_type: application/octet-stream
|
||||||
|
Loading…
x
Reference in New Issue
Block a user