Skip to content

Commit

Permalink
ci: Update release workflow to use arbitrary references
Browse files Browse the repository at this point in the history
This allows unnamed references to be released, which is necessary now that
the release workflow produces tag references.
  • Loading branch information
olix0r committed Mar 20, 2024
1 parent 3837465 commit 8f58beb
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ on:
required: false
type: boolean
default: false
ref:
description: "Reference of the commit to release (default: github.ref)"
required: false
type: string
default: ""

env:
CARGO_INCREMENTAL: 0
Expand All @@ -43,14 +48,13 @@ jobs:
steps:
- id: meta
env:
SHA: ${{ github.sha }}
VERSION: ${{ inputs.version }}
shell: bash
run: |
set -euo pipefail
shopt -s extglob
if [[ '${{ github.event_name }}' == "pull_request" ]]; then
echo version="0.0.0-test.${SHA:0:7}"
echo version="0.0.0-test.${GITHUB_SHA:0:7}"
echo archs='["amd64"]'
exit 0
fi >> "$GITHUB_OUTPUT"
Expand Down Expand Up @@ -78,6 +82,7 @@ jobs:
version: ${{ steps.meta.outputs.version }}
package: ${{ github.event_name == 'workflow_dispatch' || steps.changed.outputs.any_changed == 'true' }}
profile: ${{ inputs.profile || 'release' }}
ref: ${{ inputs.ref || github.ref }}

info:
needs: meta
Expand All @@ -91,10 +96,12 @@ jobs:
echo 'inputs.tag-prefix: ${{ inputs.tag-prefix }}'
echo 'inputs.profile: ${{ inputs.profile }}'
echo 'inputs.publish: ${{ inputs.publish }}'
echo 'inputs.ref: ${{ inputs.ref }}'
echo 'needs.meta.outputs.archs: ${{ needs.meta.outputs.archs }}'
echo 'needs.meta.outputs.version: ${{ needs.meta.outputs.version }}'
echo 'needs.meta.outputs.package: ${{ needs.meta.outputs.package }}'
echo 'needs.meta.outputs.profile: ${{ needs.meta.outputs.profile }}'
echo 'needs.meta.outputs.ref: ${{ needs.meta.outputs.ref }}'
package:
needs: meta
Expand All @@ -118,6 +125,8 @@ jobs:
- name: Configure git
run: git config --global --add safe.directory "$PWD" # actions/runner#2033
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
with:
ref: ${{ needs.meta.outputs.ref }}
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84
with:
key: ${{ matrix.libc }}
Expand Down Expand Up @@ -146,6 +155,8 @@ jobs:
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
# Tag the release.
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
with:
ref: ${{ needs.meta.outputs.ref }}
- run: git tag -a -m "v${{ needs.meta.outputs.version }}" "$TAG"
# Fetch the artifacts.
- uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427
Expand Down

0 comments on commit 8f58beb

Please sign in to comment.